Meteor ROOT_URL variable causing either white screen on iOS/Android deployment or accounts-facebook redirect issues

I’m facing a pretty complicated case with Meteor, mupx and ROOT_URL environment variable.

I’m working on meteor-1.2.1 app with React with Facebook login. When setting ROOT_URL global variable inside app code, it works perfectly fine on local development as well as on meteor run ios/android.

Then I’m deploying the app to Digital Ocean server with mupx and making a build for iOS and Android with meteor build ./build --server=http://xxxxxx.com pointing to Digital Ocean server. It works good in the web browser, but after installing my app to iOS through iTunes or AppStore, the app is getting stuck with white screen right after splash screen, but only on first launch. Once again, this happens ONLY ONCE right after app installation. If I close the app and reopen it again, it will load correctly and continues working normally. The same is happening on Android device as well.

Here are my files:


**** settings.json ****

{
  "rootUrl": "http://xxxxxx.com",
  "facebook": {
    "appId": "xxxxxxxxxxxxxxxxxxxxx",
    "secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "loginStyle": "redirect"
  },
}

**** mup.json ****

{
  "servers": [
    {
      "host": "xxxxxx.com", // actual server
      "username": "user",
      "pem": "~/.ssh/pem.key",
      "env": {}
    }
  ],
  "env": {
    "PORT": 80,
    "ROOT_URL": "http://xxxxxx.com"
  },
  "setupMongo": true,
  "setupNode": true,
  "nodeVersion": "0.10.40", // "0.10.43" for meteor-1.3
  "setupPhantom": true,
  "enableUploadProgressBar": true,
  "appName": "xxxxxx",
  "app": "../../app",
  "deployCheckWaitTime": 60
}

**** lib/_global.js ****

ROOT_URL = Meteor.settings.rootUrl;

**** server/accounts.js ****

ServiceConfiguration.configurations.upsert(
  { service: "facebook" },
  {
    $set: {
      appId: Meteor.settings.facebook.appId,
      secret: Meteor.settings.facebook.secret,
      loginStyle: Meteor.settings.facebook.loginStyle
    }
  }
);

I know it’s pretty hard to find a problem in this case, but I’m guessing it has to do with either Meteor with ROOT_URL, or mupx. It took me a very long time to debug and find that the issue is actually happening because of ROOT_URL variable.

PS: You would ask why would I set this global variable inside app code? That’s because accounts-facebook doesn’t redirect properly after successful login, but hangs on blank Facebook screen. http://stackoverflow.com/questions/28080036/meteor-facebook-authorization-simply-isnt-working

If I will remove ROOT_URL from in-app code, white screen issue disappears, but then facebook login doesn’t redirect properly. Let’s assume Facebook is setup correctly with Deauthorize Callback URL = http://xxxxxx.com/_oauth/facebook.

PPS: Tried updating the app to meteor v1.3-rc.13 as well. Same thing.

Any help will be much appreciated.

Hello ,
Did you solve this issue ?