OSPanel / OpenServerPanel

Software environment for web development
https://ospanel.io
Other
309 stars 38 forks source link

Access-Control-Allow-Origin contains multiple values #22

Closed hungnc89 closed 2 months ago

hungnc89 commented 2 months ago

image

image

I am using ospanel 6.0.0 and I am experiencing issues with sending AJAX requests, causing the browser to encounter CORS errors.

The browser notice issue : Access to fetch at 'http://waterfalls.local/api/v1/user/login' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values ', ', but only one is allowed. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Sorry if I wrong.

delphinpro commented 2 months ago

The "Access-Control-Allow-Origin" header is already registered in Apache configurations for all versions of PHP. If you add a header in your scripts, you will get a duplicate. Try to edit the config/.../httpd.conf file according to your needs.

hungnc89 commented 2 months ago

Thank you, as you suggested, I tried removing the allowed origins in my Laravel project, and it worked fine. This behavior is different from version 5 when I configured it with Nginx.