1
votes

I'm working with laravel, using Cors and passport. Everything works great but authentication with the route ({{HOST/oauth/token}}) is not working always get

"Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource"

every other route is working perfectly. SO I just need to tell passport to use cors, I have tried this

In AuthServiceProvider

Passport::routes(null, ['middleware' => [\Barryvdh\Cors\HandleCors::class]]);

and this

 Route::group(['middelware' => 'cors'], function () {
        Passport::routes();
         });

but nothing, login with oauth no working at all. Thank you in advance!!!

1

1 Answers

1
votes

change the middleware statement to

Passport::routes(null, ['middleware' => [ \Barryvdh\Cors\HandleCors::class ]]);

refer to https://github.com/barryvdh/laravel-cors/issues/243