[ANDROID] Access to XMLHttpRequest Request Blocked Meteor 1.8.1

#1

Hi Everyone

Recently I got this error while running the Android app. The App is working fine a few days back
The server is configured with NGINX and configuration not changed. Also, this request is also not redirected to https

Note: The WEB & iOS App Are working fine

server {
listen 0.0.0.0:80;
server_name sitename.com www.sitename.com;
return 301 https://www.sitename.com$request_uri;
}

server {
listen 80;
server_name sitename.com www.sitename.com;
return 301 $scheme://www.sitename.com$request_uri;
}

Access to XMLHttpRequest at ‘http://sitename.com/sockjs/info?cb=y37xb96qle’ from origin ‘http://localhost:12160’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.", source: http://localhost:12160/page

I have added this

1. WebApp.rawConnectHandlers.use(function(req, res, next) {
    res.setHeader("Access-Control-Allow-Origin", "*");
    return next();
});
2. App.accessRule('*');
3. WebApp.connectHandlers.use(cors(corsOptions));// CORS package
4. While creating Meteor Build added port with the IP Address

Also Attaching the NGINX Configuration

       server {
    listen 0.0.0.0:80;
    server_name sitename.com www.sitename.com;

   return 301 https://www.sitename.com$request_uri;
}

# optional - listen to a www. request and strip out the www.
server {
      listen 80;
     server_name sitename.com www.sitename.com;
        return 301 $scheme://www.sitename.com$request_uri;
}

# after the request has been forwarded to an ssl domain
# listen on port 443 and turn ssl sockets on
server {
      listen 443;
      # --
      # this could be your IP address, a subdomain or a full domain
      # --
      server_name sitename.com www.sitename.com;
      ssl_certificate /etc/nginx/ssl/www_sitename_com/ssl-bundle.crt;
     ssl_certificate_key /etc/nginx/ssl/www_sitename_com/example_com.key;
    # side note: only use TLS since SSLv2 and SSLv3 have had recent vulnerabilities
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        #ssl_certificate /var/www/html/ssl/ssl-bundle.crt;
        #ssl_certificate_key /var/www/html/ssl/example_com.key;
      ssl on;
      access_log /var/log/nginx/access.plygrid.log;
      error_log /var/log/nginx/error.plygrid.log;
      location / {
            proxy_pass http://localhost:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            add_header 'Access-Control-Allow-Origin' '*';

            add_header              'Access-Control-Allow-Credentials: true' always;
            add_header              'Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS' always;
            add_header              'Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,access_token,__setXHR_' always;
            if ($request_method = 'OPTIONS') {
                add_header          'Access-Control-Max-Age' 1728000;
                add_header          'Content-Type' 'text/plain charset=UTF-8';
                add_header          'Content-Length' 0;
                return              204;
            }
    }

}

Is there Anyone getting the same issue? Please help its very urgent!

#2

Downgrading to Meteor 1.8.0.2 Solved the issue!!

1 Like