diff --git a/android/capacitor/src/main/java/com/getcapacitor/Bridge.java b/android/capacitor/src/main/java/com/getcapacitor/Bridge.java index d156b918c..a87ec1bc0 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/Bridge.java +++ b/android/capacitor/src/main/java/com/getcapacitor/Bridge.java @@ -191,9 +191,16 @@ private void loadWebView() { authorities.add(appUrlObject.getAuthority()); } catch (Exception ex) { } - + localUrl = appUrlConfig; + appUrl = appUrlConfig; if (BuildConfig.DEBUG) { - Toast.show(getContext(), "Using app server " + appUrlConfig.toString()); + Toast.show(getContext(), "Using app server " + appUrlConfig); + } + } else { + appUrl = localUrl; + // custom URL schemes requires path ending with / + if (!scheme.equals(Bridge.CAPACITOR_HTTP_SCHEME) && !scheme.equals(CAPACITOR_HTTPS_SCHEME)) { + appUrl += "/"; } } @@ -203,16 +210,6 @@ private void loadWebView() { localServer = new WebViewLocalServer(context, this, getJSInjector(), authorities, html5mode); localServer.hostAssets(DEFAULT_WEB_ASSET_DIR); - if (appUrlConfig == null) { - appUrl = localUrl; - // custom URL schemes requires path ending with / - if (!scheme.equals(Bridge.CAPACITOR_HTTP_SCHEME) && !scheme.equals(CAPACITOR_HTTPS_SCHEME)) { - appUrl += "/"; - } - } else { - appUrl = appUrlConfig; - } - Log.d(LOG_TAG, "Loading app at " + appUrl); webView.setWebChromeClient(new BridgeWebChromeClient(this)); diff --git a/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java b/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java index 4bf058549..e745d45c0 100755 --- a/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java +++ b/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java @@ -172,7 +172,7 @@ public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) { return null; } - if (isLocalFile(loadingUrl) || loadingUrl.toString().startsWith(bridge.getLocalUrl())) { + if (isLocalFile(loadingUrl) || Config.getString("server.url") == null) { Log.d(LogUtils.getCoreTag(), "Handling local request: " + request.getUrl().toString()); return handleLocalRequest(request, handler); } else {