'blocked by CORS :The 'Access-Control-Allow-Origin' header contains multiple values '*, *', Laravel8
Access to XMLHttpRequest at 'http://localhost:8000/api/objectives' from origin 'http://localhost:4200' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.
Solution 1:[1]
First solution is to use this library https://github.com/fruitcake/laravel-cors
second one is adding header('Access-Control-Allow-Origin: *');
to your public/index.php that may fix the problem
Solution 2:[2]
Head over to the cors.php in config folder and change this 'allowed_origins_patterns' => [],
to 'allowed_origins_patterns' => ['*'],
Solution 3:[3]
Try changing this 'supports_credentials' => false,
to 'supports_credentials' => true,
in the cors.php file located in the configs file Learn more
Solution 4:[4]
I ran into similar issues. In my case, I fixed it by removing
Header set Access-Control-Allow-Origin "*"
from my .htaccess file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | mj.akbarian |
Solution 2 | Arnoldkk |
Solution 3 | Arnoldkk |
Solution 4 | Md. Zubaer Ahammed |