Reputation: 513
I am ridiculously trying to get CORS working on Meteor 1.8, suddenly had this problem in my app:
" I chromium: [INFO:CONSOLE(0)] "Access to XMLHttpRequest at 'http://192.168.1.14/sockjs/info?cb=3lc2_ftamu' from origin 'http://localhost:12368' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.", source: http://localhost:12368/ (0)"
It only appears on Android and iOS, not when running web-only.
I searched all the stack overflow and Meteor help and forums, tried:
WebApp.rawConnectHandlers.use(function(req, res, next) {
res.setHeader("Access-Control-Allow-Origin", "*");
return next();
});
Also tried in mobile_config.js:
App.accessRule('*');
I also tried other headers on the server, updated Meteor, tried with the cors package:
...
WebApp.connectHandlers.use(cors(corsOptions));
and all the other common things when Meteor Cordova isn't running.
Any idea?
Upvotes: 3
Views: 373
Reputation: 513
Wow, I forgot the port (:3000) in the http-address for the root and mobile-server like so:
So should be
meteor run android --mobile-server http://ip-addr:3000
Ip-addr should be your local IP address. I just forgot the :3000 to tell the Cordova version on Android that the app runs locally on port 3000.
Upvotes: 1