Skip to content

Conversation

@cpojer
Copy link

@cpojer cpojer commented Nov 28, 2024

When using a local server.errorPath in conjunction with a remote server.url, and the device is offline, Capacitor does not inject its JS because allowedOrigin will be set to the remote server.url hostname, while the error is loaded from the local server. This means that plugins and other Capacitor/Cordova functionality are unavailable in this situation.

This PR adds https://localhost as an allowedOrigin, ensuring that all the Capacitor JS is being included in the error case.

There is a related PR for the case when the document start script feature is not supported: #6247

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant