I'm working on a project and i'm using ReactJs for the frontend and Laravel 7 for the backend.
Apparently the 'Allow-Origin' header in the response is still returning "*" even though I configured Cors in Laravel, every time I make a request with axios I get this error "The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'" and yes, I use withCredentials because in the Laravel documentation it says that we must allow credentials.
PS: Please, don't mark it as duplicate, I checked the previous questions and our problems are a little bit different and I couldn't find a useful answer
This is my config/cors.php file
'paths' => ['api/*', 'sanctum/csrf-cookie', '/login'],
'allowed_methods' => ['*'],
'allowed_origins' => ['http://127.0.0.1:3000'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => true,
];
This is the middleware Cors.php file
public function handle($request, Closure $next)
{
return $next($request)
->header('Access-Control-Allow-Origin', 'http://127.0.0.1:3000')
->header('Access-Control-Allow-Methods', "PUT, POST, GET, DELETE, OPTIONS")
->header('Access-Control-Allow-Headers', "Accept, Authorization, Content-Type")
->header('Access-Control-Allow-Credentials', "true");
}