前端简单易操作的内网穿透工具localtunnel

慈云数据 12个月前 (04-01) 技术支持 56 0

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
  });
})();
微信扫一扫加客服

微信扫一扫加客服