user3425765
user3425765

Reputation: 291

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

I'm making a Chrome plugin that calls a PHP script on my server, but I keep getting the "No 'Access-Control-Allow-Origin' header is present on the requested resource." error.

I have added the header settings in my Nginx config, so I have no idea what else could be the problem.

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;
}

Upvotes: 3

Views: 6581

Answers (1)

PaulSchell
PaulSchell

Reputation: 182

  1. Do you have http://wiki.nginx.org/NginxHttpHeadersModule enabled?
  2. https://gist.github.com/michiel/1064640 a CORS Script.
  3. Dont forget to clear the cache!

Upvotes: 1

Related Questions