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

WebView feature suggestion: custom URI scheme and resource domain #48

Closed
awood314 opened this issue Mar 13, 2024 · 4 comments
Closed

WebView feature suggestion: custom URI scheme and resource domain #48

awood314 opened this issue Mar 13, 2024 · 4 comments

Comments

@awood314
Copy link

When using the WebView with the fetchResource option, we get blocked by CORS security protection when web resources make HTTP requests to our back-end services. In order to be deliberate about what origin those services see and allow, something we've implemented in our fork is the ability to override the components of the URI scheme:

  • on Mac, the choc:// application URI scheme and choc.choc domain
  • on Windows, the choc.localhost domain

This doesn't implement Linux, but just thought I'd drop it here in case you may find it useful: splice#1

Thanks!

@julianstorer
Copy link
Collaborator

Hi Alex

Someone else had a similar problem and we solved it with this commit:
77c6a89

Does that work for you?

@awood314
Copy link
Author

Unfortunately not. I believe that would fix CORS issues for navigation requests, but then you run into cross-origin problems when those resources make requests via XHR/fetch from javascript.

As far as I can tell, aside from making changes to the back-end to send the appropriate CORS headers to the allowed origin, the only ways around this on the client side are:

@dbadb
Copy link

dbadb commented Mar 16, 2024

I have a change in my branch that supports a user-provided options customUriScheme, customUriHome (following the pattern of userAgent) to specify the scheme and domain. Change was quite simple and can be seen here:

cannerycoders@3fe379c

I originally implemented it as an #ifdef, but found the need for multiple schemes within the same runtime.

@julianstorer
Copy link
Collaborator

I've implemented this with a few differences, but should do what you need. Let me know if it gives you any trouble..

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

No branches or pull requests

3 participants