0

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.

4
  • Fix your application. It sends null
    – Alexey Ten
    Commented Feb 3, 2017 at 7:17
  • created a new application with very less commands, and it is not showing the null error now, instead it show - Request CORS header - Access-Control-Allow-Origin is missing Commented Feb 3, 2017 at 8:50
  • BTW, Access-Control-Allow-Origin must not contain path. In your case it should be just http://localhost:9090
    – Alexey Ten
    Commented Feb 3, 2017 at 15:03
  • @AlexeyTen The problem still remains the same. Any other solution? Thanks in advance Commented Feb 6, 2017 at 8:38

1 Answer 1

-1

Directive add_header modifies the response. Try use proxy_set_header to add the header to the request.

1
  • When using proxy_set_header it shows - > Request CORS header - Access-Control-Allow-Origin is missing Commented Feb 3, 2017 at 8:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .