Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,12 @@ private void loadWebView() {
// Start the local web server
JSInjector injector = getJSInjector();
if (WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) {
String allowedOrigin = Uri.parse(appUrl).buildUpon().path(null).fragment(null).clearQuery().build().toString();
Set<String> allowedOrigins = new HashSet<>(Arrays.asList(
Uri.parse(appUrl).buildUpon().path(null).fragment(null).clearQuery().build().toString(),
"https://localhost"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there ever a situation where we'd also want to add http://localhost?

));
try {
WebViewCompat.addDocumentStartJavaScript(webView, injector.getScriptString(), Collections.singleton(allowedOrigin));
WebViewCompat.addDocumentStartJavaScript(webView, injector.getScriptString(), allowedOrigins);
injector = null;
} catch (IllegalArgumentException ex) {
Logger.warn("Invalid url, using fallback");
Expand Down