Nginx CORS error is not going away.
I am using Debian Jessie and below is the and sites-available/reverse.conf
Reverse.conf is the file i created for reverse proxy.
I am getting this CORS error on login page.
I tried adding the header Access-Control-Allow-Origin and setting its value as * and the URL the request is going to.
Any help would be appreciated.
Thanks in advance
server {
listen 9090;
location / {
root /usr/share/nginx/html/Usecase3;
index index.html index.htm;
}
location /platform/security/admin/beta/login {
proxy_pass http://localhost:8090/platform/login;
add_header Access-Control-Allow-Origin http://localhost:9090/platform/login;
}
}
Tried putting the URL in quotes,
Tried using '*' i.e. allow all,
but nothing is working out.
Error –
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:9090/platform/login. (Reason: CORS header 'Access-Control-Allow-Origin' does not match 'null, http://localhost:9090/platform/login').
And why is the null keyword appearing above in the error?
Thanks in advance.
Best Answer
Directive add_header modifies the response. Try use proxy_set_header to add the header to the request.