登录 (opens new window) 使用 github 的 learn01sz 授权登录后在下面地址拿到身份令牌 https://dashboard.ngrok.com/get-started/setup/windows
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
server: {
allowedHosts: true,
host: '0.0.0.0'
}
})
下载完成的 ngrok.exe 放到指定文件夹如"D:\tool\ngrok"
cd D:\tools\ngrok
.\ngrok.exe config add-authtoken 你的Authtoken字符串 #只需要执行一次
# 穿透web网站
.\ngrok.exe http 5173 # 5173需要代理的端口号
.\ngrok.exe http 5173 --basic-auth "dev:123456" # 访问时需要输入账号dev、密码123456
# TCP 端口穿透(SSH / 数据库等场景)
.\ngrok.exe tcp 22