Nginx no';访问控制允许来源';头球


Nginx no 'Access-Control-Allow-Origin' header

我正在制作一个Chrome插件,该插件在我的服务器上调用PHP脚本,但我一直收到"请求的资源上不存在‘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. 你有吗http://wiki.nginx.org/NginxHttpHeadersModule启用
  2. https://gist.github.com/michiel/1064640CORS脚本
  3. 别忘了清理缓存