I’m getting “Access to XMLHttpRequest at ‘http://host/endpoint’ from origin ‘http://host’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.” when I use both “CorsMiddleware” and “AuthMiddlware”(NOTE: Both are custom middlewares)
Bootstrap/App.php
->withMiddleware(function (Middleware $middleware) { $middleware->alias([ 'CorsMiddleware' => CorsMiddleware::class, 'AuthMiddleware' => AuthMiddleware::class ]); })
Routes/Api.php
Route::controller(controller::class)->group( function () { Route::get('/sample/index', 'index'); ... other routes } )->middleware('CorsMiddleware');
I’m expecting my AuthMiddleware to check if the requestor is authenticated or something like that.
Thank you for your answers!
Jimmark Daroy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.