lundi 8 avril 2019

Laravel CORS: OPTIONS method not allowed for API routes, but working for web routes

Laravel 5.7 I'm getting a "405 Method Not Allowed" error during CORS preflight with OPTIONS method, but only on my api routes.

I've tried https://github.com/barryvdh (I'm using this for web routes and it works fine). I've also tried this and some simpler custom CORS middleware.

I've also tried adding a specific handler for the OPTIONS method in my API routes ($router->options('{all}', 'OptionsController@options')->where('all', '.*');) and then handled it appropriately.

With all this testing, I'm suspicious that there is something other than an incorrect CORS middleware setup that is preventing OPTIONS methods from accessing API routes. Does anyone know what the problem might be?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire