1.localtunnel介绍
生成唯一可在公网访问的url,该url会代理本地运行的web服务请求,localtunnel是部署在国外的,访问比较慢。
优势:部署方便,不需要部署测试环境,为了方便向世界暴露你的项目,而且修改起来也是很方便。
2.使用方法
快速开始
npx localtunnel --port 8000
全局安装
npm install -g localtunnel
或者
yarn global add localtunnel
当全局安装了 localchannel 时,只需使用 lt 命令启动即可。
lt --port 8000
自定义个性前缀
lt --subdomain --port
例如:
在代码中使用
const localtunnel = require('localtunnel'); (async () => { const tunnel = await localtunnel({ port: 3000 }); // the assigned public url for your tunnel // i.e. https://abcdefgjhij.localtunnel.me tunnel.url; tunnel.on('close', () => { // tunnels are closed }); })();