diff --git a/android/capacitor/src/main/java/com/getcapacitor/Bridge.java b/android/capacitor/src/main/java/com/getcapacitor/Bridge.java index a4ccb09da2..555ebb9b3c 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/Bridge.java +++ b/android/capacitor/src/main/java/com/getcapacitor/Bridge.java @@ -263,7 +263,12 @@ private void loadWebView() { allowedOrigin = appUri.toString().replace(appUri.getPath(), ""); } } - WebViewCompat.addDocumentStartJavaScript(webView, injector.getScriptString(), Collections.singleton(allowedOrigin)); + final String finalAllowedOrigin = allowedOrigin; + Set allowedOrigins = new HashSet() {{ + add(finalAllowedOrigin); + addAll(allowedOriginRules); + }}; + WebViewCompat.addDocumentStartJavaScript(webView, injector.getScriptString(), allowedOrigins); injector = null; } localServer = new WebViewLocalServer(context, this, injector, authorities, html5mode);