I am using \Fruitcake\Cors\HandleCors
middleware for CORS in a Laravel app.
My cors.php
file looks like this:
'paths' => ['api/*', 'oauth/*', '*'],
'allowed_methods' => ['POST', 'GET', 'DELETE', 'PUT', '*'],
'allowed_origins' => ['http://localhost:3000', 'https://localhost:3000'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => true,
I am setting cookie in response like this:
$access_cookie = Cookie::make('access_token', $access_token, $cookieLife, null, null, true);
$refresh_cookie = Cookie::make('refresh_token', $refresh_token, $MINUTES_IN_ONE_YEAR, null, null, true);
return response()
->json(['tokens' => ['access_token' => $access_token, 'refresh_token' => $refresh_token], 'user' => $user])->withCookie($access_cookie)->withCookie($refresh_cookie);
Finally, I am calling this api endpoint from React app which is running on https://localhost:3000
It gives me an error saying that CORS not allowed ( Classic CORS error ).
But when I remove the cookie from the response, then It works fine.
What other setting do I need to get it to work?