Skip to content

Commit

Permalink
include protocol in dev server origin
Browse files Browse the repository at this point in the history
  • Loading branch information
Traviskn committed Feb 15, 2018
1 parent 9c71b2a commit fe1b4ef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/utils/polyfillEnvironment.js
Expand Up @@ -42,9 +42,14 @@ const scriptURL = require('react-native').NativeModules.SourceCode.scriptURL; //
// or Android device it will be `localhost:<port>` but when using real iOS device
// it will be `<ip>.xip.io:<port>`. Thus the code below ensure we connect and download
// manifest/hot-update from a valid origin.
const match = scriptURL && scriptURL.match(/(^.+)\/index/);
let devServerOrigin = null;

global.DEV_SERVER_ORIGIN = match ? match[1] : null;
if (scriptURL) {
const [protocol, , origin]= scriptURL.split('/');
devServerOrigin = `${protocol}//${origin}`;
}

global.DEV_SERVER_ORIGIN = devServerOrigin;

// Webpack's `publicPath` needs to be overwritten with `DEV_SERVER_ORIGIN` otherwise,
// it would still make requests to (usually) `localhost`.
Expand Down

0 comments on commit fe1b4ef

Please sign in to comment.