admin管理员组文章数量:1023055
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 (e.g. ngrok), so that e.g. "myapp.example" is forwarded to my host application running on localhost, and then I could just fetch "myapp.example" from within the WebContainer. I already tried it out and this does actually work using ngrok, but it feels much more complicated than necessary.
But there must be a better solution for this kind of basic HTTP communication between host and container. How do I do this?
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 (e.g. ngrok), so that e.g. "myapp.example" is forwarded to my host application running on localhost, and then I could just fetch "myapp.example" from within the WebContainer. I already tried it out and this does actually work using ngrok, but it feels much more complicated than necessary.
But there must be a better solution for this kind of basic HTTP communication between host and container. How do I do this?
本文标签: web containerHow to communicate between the host and a WebContainerStack Overflow
版权声明:本文标题:web container - How to communicate between the host and a WebContainer? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745570814a2156726.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论