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

[CORS] allow requests to be handled by locally running proxy #882

Open
randName opened this issue Oct 29, 2022 · 3 comments
Open

[CORS] allow requests to be handled by locally running proxy #882

randName opened this issue Oct 29, 2022 · 3 comments
Labels

Comments

@randName
Copy link

randName commented Oct 29, 2022

As mentioned in many other issues (e.g. #142), CORS cannot be bypassed unless using some browser extension to work around it.

Also, using localhost to access the actual computer localhost does not really work and we have to use a workaround (e.g. the actual computer IP instead).

Describe the solution you'd like:
The idea is to allow StackBlitz to capture requests for a certain set of domains and redirect them to a locally running proxy

e.g. detect calls to https://some.noncors.api/* and transparently redirect to http://<some way of actually getting localhost>:8080/:path, and then run your own server listening at 8080 (e.g. something like this https://gist.github.com/randName/88c7c2fc7a30890ed31b0dae14b29d24 )

Describe alternatives you've considered:
for frontend apps I think http-proxy can achieve something to that effect, but if it is a pure node app you have to do it manually (e.g. override global fetch)

for example, if some library to interact with an API does not allow me to change URLs, I'm stuck unless I dig into that library.

Additional context:
I have mentioned this previously on discord, and it is even more important now that Codeflow can handle almost everything except CORS.

I can run local databases and other services but getting access to them is a bit of a pain (especially since it is not localhost and thus no longer a secure context, https is required)

@randName
Copy link
Author

randName commented Nov 1, 2022

Expanding on that last point (which admittedly is tangential to this issue), for example I want do develop something using OBS WebSocket. It is a known issue (obsproject/obs-websocket#26, WICG/private-network-access#23) that we cannot mix security contexts.

The stated solution is to use ngrok, but that assumes we can control the URL even with libraries (fortunately for OBS WebSocket, most of the time it can be done). Ideally we shouldn't need ngrok for local development.

@randName
Copy link
Author

Recently started another project that would be greatly helped by this (working with locally served map tiles that I won't want to load into the webcontainer). Having to send them for a trip around the internet via ngrok is really not ideal.

@SamVerschueren apologies for the ping, but it would be nice to know the if this is being tracked, thanks!

@SamVerschueren
Copy link
Contributor

Hi @randName. We're discussing internally how something like this could work. We do agree that having a way to send traffic to a service that runs on your host machine is a very good use case that we need to support. I will get back to you if I have more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants