jeudi 16 novembre 2017

Cors OPTIONS method in Axios fails with Laravel and Nginx

I made an webapp with (Vue)Axios. All GET-requests work perfectly, but when doing a POST-request it fails..

In the network-response I see that it sends OPTIONS instead of POST:

OPTIONS http://ift.tt/2AUoFOn

In Chrome I get this reponse:

OPTIONS http://ift.tt/2AUoFOn net::ERR_NAME_NOT_RESOLVED

And in Safari:

Failed to load resource: cancelled
XMLHttpRequest cannot load http://ift.tt/2AUoFOn due to access control checks.

This is probably failing because of the API application I wrote in Laravel 5.5. So I added this package LaravelCors. From the docs it tells me that'll fix it. The config is like this:

[
    'supportsCredentials' => true,
    'allowedOrigins'      => ['*'],
    'allowedHeaders'      => ['*'],
    'allowedMethods'      => ['*'],
    'exposedHeaders'      => [],
    'maxAge'              => 0,
]

And configured it like it's written in the docs.

But it doens't fix it at all.

Server is running on Nginx. Is thát maybe the place to configure things or can I fix it with my Laravel application?

I'm testing it all from an application from my localhost:8080.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2hElZj1
via IFTTT

Aucun commentaire:

Enregistrer un commentaire