From c2ae7903960c4cfcd46eb4962c5e6a0963f73095 Mon Sep 17 00:00:00 2001 From: Dave Sibiski Date: Wed, 14 Oct 2015 08:23:02 -0700 Subject: [PATCH] Removes hardcoded port `8081` from URL format strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: This allows the use of different bundle URLs & ports in Dev mode. (ie. ngrok url shared with a team member) The bundle URL can be changed via the normal Dev Menu, or programmatically by setting the `debug_http_host` shared preference key. For example, in your apps `MainActivity.java` before creating your `ReactRootView`: ```java SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(getApplication()); SharedPreferences.Editor editor = mPreferences.edit(); editor.putString("debug_http_host", "my.customurlandport.com:8888"); editor.commit(); ``` **Breaking change**: Custom bundle URLs added via the Dev Menu will need to also include the port. This has been noted in the documentation and also on the preference description in the Dev Menu. Addresses: https://github.com/facebook/react-native/issues/2704 Closes https://github.com/facebook/react-native/pull/2824 Reviewed By: @​svcscm Differential Revision: D2540450 Pulled By: @javache fb-gh-sync-id: a053de91e3095bb67640bb0f1b8761e55775bc9c --- .../facebook/react/devsupport/DevServerHelper.java | 14 +++++++------- .../src/main/res/devsupport/xml/preferences.xml | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java index a91312b73..b62d2d4b5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java @@ -49,19 +49,19 @@ import okio.Sink; public static final String RELOAD_APP_EXTRA_JS_PROXY = "jsproxy"; private static final String RELOAD_APP_ACTION_SUFFIX = ".RELOAD_APP_ACTION"; - private static final String EMULATOR_LOCALHOST = "10.0.2.2"; - private static final String GENYMOTION_LOCALHOST = "10.0.3.2"; - private static final String DEVICE_LOCALHOST = "localhost"; + private static final String EMULATOR_LOCALHOST = "10.0.2.2:8081"; + private static final String GENYMOTION_LOCALHOST = "10.0.3.2:8081"; + private static final String DEVICE_LOCALHOST = "localhost:8081"; private static final String BUNDLE_URL_FORMAT = - "http://%s:8081/%s.bundle?platform=android&dev=%s"; + "http://%s/%s.bundle?platform=android&dev=%s"; private static final String SOURCE_MAP_URL_FORMAT = BUNDLE_URL_FORMAT.replaceFirst("\\.bundle", ".map"); private static final String LAUNCH_CHROME_DEVTOOLS_COMMAND_URL_FORMAT = - "http://%s:8081/launch-chrome-devtools"; + "http://%s/launch-chrome-devtools"; private static final String ONCHANGE_ENDPOINT_URL_FORMAT = - "http://%s:8081/onchange"; - private static final String WEBSOCKET_PROXY_URL_FORMAT = "ws://%s:8081/debugger-proxy"; + "http://%s/onchange"; + private static final String WEBSOCKET_PROXY_URL_FORMAT = "ws://%s/debugger-proxy"; private static final int LONG_POLL_KEEP_ALIVE_DURATION_MS = 2 * 60 * 1000; // 2 mins private static final int LONG_POLL_FAILURE_DELAY_MS = 5000; diff --git a/ReactAndroid/src/main/res/devsupport/xml/preferences.xml b/ReactAndroid/src/main/res/devsupport/xml/preferences.xml index f7eb6a5fb..ee1e7c4bd 100644 --- a/ReactAndroid/src/main/res/devsupport/xml/preferences.xml +++ b/ReactAndroid/src/main/res/devsupport/xml/preferences.xml @@ -38,8 +38,8 @@ />