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.

  • Fix your application. It sends null – Alexey Ten Feb 3 '17 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 – Arpit Gupta Feb 3 '17 at 8:50
  • BTW, Access-Control-Allow-Origin must not contain path. In your case it should be just http://localhost:9090 – Alexey Ten Feb 3 '17 at 15:03
  • @AlexeyTen The problem still remains the same. Any other solution? Thanks in advance – Arpit Gupta Feb 6 '17 at 8:38

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

| improve this answer | |
  • When using proxy_set_header it shows - > Request CORS header - Access-Control-Allow-Origin is missing – Arpit Gupta Feb 3 '17 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.