8

请教一下使用 VSCode 连接 WSL 开发,怎么将 WSL 中的端口号转发出来以在 win 下访问...

 1 year ago
source link: https://www.v2ex.com/t/940456
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Visual Studio Code

请教一下使用 VSCode 连接 WSL 开发,怎么将 WSL 中的端口号转发出来以在 win 下访问?

  cogear · 4 小时 16 分钟前 · 531 次点击

项目在 WSL 启动之后,监听 3000 端口,在宿主 win 中没法直接访问。

started server on 0.0.0.0:3000, url: http://localhost:3000

网上给出的解决方案是 Remote Explorer 中可以编辑端口映射,但是我并没有找到,

Control Shift + P 搜索 Port 或者 Forward 关键字也没搜索到相关的。


我记得之前连接到 docker container 中会有 port forward 的,是因为直接连 wsl 没这个功能?

第 1 条附言  ·  3 小时 20 分钟前

此问题已解决

首先,我想访问WSL中的web app,不需要端口转发

根据WSL的官方文档,理应无需配置即可使用localhost直接访问WSL中的web app。

我无法通过localhost访问,应该是公司电脑被group policy统一配置的防火墙策略限制了。

即使无法通过localhost访问,根据文档的提示,我可以通过WSL的ip来访问。 https://learn.microsoft.com/zh-cn/windows/wsl/networking


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK