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

How to communicate between the host and the container? #1617

Open
henophilia opened this issue Nov 18, 2024 · 0 comments
Open

How to communicate between the host and the container? #1617

henophilia opened this issue Nov 18, 2024 · 0 comments

Comments

@henophilia
Copy link

I have a use case where I would like my main application to call API endpoints exposed by the application running within the Webcontainer and vice versa. When my host server is running locally at localhost:3000 and I call fetch("http://localhost:3000/api/...") from within the Webcontainer, obviously it doesn't work, because that API endpoint does not exist within the container.

I already thought of a few rather "hacky" solutions, such as:

  • Writing a file to the Webcontainer's file system whenever I want to communicate with it, and polling for changes within the Webcontainer.
  • Using some sort of reverse proxy, so that e.g. "myapp.example.com" is forwarded to my host application running on localhost, and then I could just fetch "myapp.example.com" from within the Webcontainer.

But there must be a better solution for this kind of basic HTTP communication between host and container. How do I do this?

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

1 participant