Firefox不接受Access-Control-Allow-Origin:*

时间:2016-07-07 03:37:40

标签: ajax http-headers cors cross-domain

我想允许访问我服务器上的所有来源,但我在Firefox中http://localhost:8100/的AJAX请求一直被拒绝。

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");;
  

“阻止跨源请求:同源策略不允许   在https://my-domain.com/userLogin读取远程资源。   (原因:CORS标题'Access-Control-Allow-Origin'不匹配   '*')。“

Firefox似乎不明白“*”字符是“通配符”的来源(并不是字面上的原因)。如果我更改下面的标题,这可以很好地工作。

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

知道为什么Firefox不接受“*”?

enter image description here

1 个答案:

答案 0 :(得分:1)

如果你只想让你的firefox启用CORS:
https://addons.mozilla.org/fr/firefox/addon/cors-everywhere/