Firefox does not accept Access-Control-Allow-Origin: *

这一生的挚爱 提交于 2019-12-24 03:08:11

问题


I want to allow access to all origins on my server, but my AJAX requests from http://localhost:8100/ in Firefox keep being rejected.

header("Access-Control-Allow-Origin: *"); // allow the use of requests in development (ionic serve in web browser).
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Max-Age", "3600");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");;

"Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://my-domain.com/userLogin. (Reason: CORS header 'Access-Control-Allow-Origin' does not match '*')."

Firefox seems NOT to understand that the "*" character as a "wildcard" origin (and not to be taken literally as the origin). If I change the header as below, this works perfectly.

header("Access-Control-Allow-Origin: http://localhost:8100");

Any idea why Firefox won't accept the "*"?


回答1:


In the case you just want YOUR firefox to enable CORS :
https://addons.mozilla.org/fr/firefox/addon/cors-everywhere/



来源:https://stackoverflow.com/questions/38237187/firefox-does-not-accept-access-control-allow-origin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!