简体   繁体   English

如何在本地 WiFi 上公开从 WSL 运行的服务器/网站/服务?

[英]How to expose server/website/service running from WSL on local WiFi?

In a project I'm using Storybook and when running the development server of Storybook it's available on the local.network.在我使用 Storybook 的项目中,当运行 Storybook 的开发服务器时,它在 local.network 上可用。

在此处输入图像描述

I run the code on WSL2 on Windows 10, and I can reach the site on the stated local.network fine from my desktop browser, but not my mobile browser.我在 Windows 10 上运行 WSL2 上的代码,我可以通过我的桌面浏览器正常访问指定的 local.network 上的站点,但不能通过我的移动浏览器访问。

My desktop is connected to the router via Ethe.net, my mobile is connected to WiFi on the same router, however, I can't connect to the Storybook server on the local.network IP stated in the image above.我的桌面通过 Ethe.net 连接到路由器,我的手机连接到同一路由器上的 WiFi,但是,我无法连接到上图中所述的 local.network IP 上的 Storybook 服务器。

My IPconfig output:我的 IP 配置 output:

在此处输入图像描述

I've also tried connecting the Storybook server on both the IPv4 addresses above (with port 6006), but no connection.我还尝试在上面的两个 IPv4 地址(使用端口 6006)上连接 Storybook 服务器,但没有连接。

Anybody know how to expose the Storybook server running on WSL2 on my WiFi?有人知道如何在我的 WiFi 上公开运行在 WSL2 上的 Storybook 服务器吗?

在此处输入图像描述

There's now a simple npm package for this.现在有一个简单的npm package

You simply have to run this before starting your dev server.您只需在启动开发服务器之前运行它。

npx expose-wsl@latest

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 命令 C 不会停止本地服务器在 VS 代码上运行 - Command C do not stop local server from running on VS code 运行 WSL 时如何在 Windows 中设置 VS 代码调试? - How to setup VS code debugging in Windows when running WSL? 如何从反应中删除本地服务器 - How to remove local server from react 如何使用 ngrok 公开 React 开发服务器和 websocket 服务器 - How to expose both React development server and websocket server with ngrok 当数据和服务器位于本地时,如何模仿从服务器接收数据? - How to mimic receiving data from a server when data and server are local? React Js Project未运行Webpack本地服务器 - React Js Project not running Webpack local server 运行 React 应用程序的 docker 容器在哪个端口? Reacts 的默认端口或来自 Dockerfile 的 EXPOSE? - On what PORT is my docker container with a React app running? Reacts' default PORT or EXPOSE from Dockerfile? 从 React 切换到 Next.js 后,由于 Service Worker 的缓存,网站没有刷新。 如何强制更新? - A website is not refreshing because of caching of service worker, after switching from React to Next.js. How to force update? CORS 标头未在 react/axios 中公开,即使标头在 Access-Control-Expose-Headers 中列出以响应服务器 - CORS headers are not exposed in react/axios even if the headers are listed in Access-Control-Expose-Headers in response from server ReactJS:如何在本地服务器上部署 - ReactJS: How to deploy on local server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM