Nginx没有'Access-Control-Allow-Origin'标题

时间:2014-10-02 21:34:36

标签: php nginx

我制作了一个Chrome插件,可以在我的服务器上调用PHP脚本,但我不断获得" No' Access-Control-Allow-Origin'标头出现在请求的资源上。"错误。

我在Nginx配置中添加了标题设置,所以我不知道还有什么问题。

location / {
     add_header 'Access-Control-Allow-Origin' '*';
     add_header 'Access-Control-Allow-Credentials' 'true';
     add_header 'Access-Control-Allow-Methods' 'GET';

     try_files $uri $uri/ /index.html;
}

1 个答案:

答案 0 :(得分:1)

  1. 您是否启用了http://wiki.nginx.org/NginxHttpHeadersModule
  2. https://gist.github.com/michiel/1064640一个CORS脚本。
  3. 别忘了清除缓存!
相关问题