Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject Capacitor JS for error fallbacks. #7781

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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