简体   繁体   中英

meteor nginx and the 'Access-Control-Allow-Origin' header, A circle here

here is the thing

everything works well before I use nginx. on server, I deployed a mobile app server using mup, and after using nginx I got a

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http ://meteor.local' is therefore not allowed access.

and then I think I should add the header in nginx, so I add the following in nginx

add_header Access-Control-Allow-Origin $http_origin;

then I got

The 'Access-Control-Allow-Origin' header contains multiple values 'http ://meteor.local, http: //meteor.local', but only one is allowed. Origin 'http: //meteor.local' is therefore not allowed access

and if I change the add_header with

add_header Access-Control-Allow-Origin *;

then I got

The 'Access-Control-Allow-Origin' header contains multiple values 'http: //meteor.local, *', but only one is allowed. Origin 'http: //meteor.local' is therefore not allowed access

I want to know how to fix this and what happens here.

btw, I have tried http://enable-cors.org/server_meteor.html , and I have App.accessRule("*"); in my mobile-config.js

plus:

my server is deployed at 8001 port, but I got an info say that

XMLHttpRequest cannot load http: //my.site.com/__cordova/manifest.json

this file does not exist apparently, it locate at http: //my.site.com:8001/__cordova/manifest.json

my question is where send this request?

I fixed it.

All things here is not about nginx, it's about the ROOT_URL of meteor app. It can work well by setting the ROOT_URL with " http://my.site.com " along with the PORT env when you connect using browser, but if the client is cordova, you have to make your ROOT_URL " http://my.site.com:port "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM