Nginx CORS doesn't work for POST

Viewed 12029

I have this configuration in my Nginx

server {
    listen       8080;

add_header    Access-Control-Allow-Origin *;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Content-Type';
}

Now I have my web application which does GET and POST for GET It works fine but if I do Ajax POST I get this error

XMLHttpRequest cannot load 'URL' . Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'Origin' is therefore not allowed access. The response had HTTP status code 404.

If I do a 'GET' request I can see this in my response.

Access-Control-Allow-Headers:Content-Type
Access-Control-Allow-Methods:GET, POST, OPTIONS
Access-Control-Allow-Origin:*

But if I make a post I don't see any of that.

1 Answers
Related