如何在子路径部署VS Code Web服务?
将VS Code Web部署到子路径的方法
VS Code的code命令提供serve-web选项,可启动Web服务器供浏览器访问,默认部署在根路径(如示例中的http://127.0.0.1:8000),示例启动命令如下:
% code serve-web --without-connection-token * Visual Studio Code Server * * By using the software, you agree to * the Visual Studio Code Server License Terms and * the Microsoft Privacy Statement. * Web UI available at http://127.0.0.1:8000
问题
如何将该VS Code实例部署在子路径(如http://127.0.0.1/ide)而非根路径?
解决方法
使用--path参数指定子路径即可,配合现有参数执行命令:
code serve-web --without-connection-token --path /ide
执行后,VS Code Web的访问地址会变为http://127.0.0.1:8000/ide。
如果需要将端口改为80(访问时无需输入端口号),可以加上--port参数:
code serve-web --without-connection-token --path /ide --port 80
此时访问地址就是http://127.0.0.1/ide。
注意:如果使用反向代理配合部署,需要确保代理服务器也配置对应的子路径转发规则;仅使用VS Code自带的
serve-web时,--path参数可直接生效。
内容的提问来源于stack exchange,提问作者Mohamed
相关产品推荐
相关产品推荐

