🌐Ngrok 部署
00 分钟
2024-4-29
2024-4-29
type
status
date
slug
summary
tags
category
icon
password
URL

安装方式

  1. 下载和安装:
      • 首先,你需要到 ngrok 的官方网站(https://ngrok.com/)上下载 ngrok 的客户端。
      • 解压下载的文件,并将 ngrok 客户端保存到一个方便访问的位置。
      • MAC 上安装
  1. 获取 Authtoken:
      • 在使用 ngrok 之前,你需要注册 ngrok 帐户并获取 Authtoken。这个 Authtoken 是用来验证你的 ngrok 客户端的身份的。
      • 在终端中运行以下命令以进行身份验证:./ngrok authtoken your_auth_token(将 your_auth_token 替换为你的 Authtoken)。
  1. 启动 ngrok:
      • 打开终端,并导航到保存 ngrok 客户端的目录。
      • 运行 ./ngrok http port_number 命令,其中 port_number 是你本地服务器运行的端口号。
      • 例如,如果你的本地服务器在端口 3000 上运行,你可以运行 ./ngrok http 3000
  1. 使用 ngrok:
      • 运行上述命令后,ngrok 将会生成一个随机的公共 URL,用于访问你的本地服务器。
      • 在终端窗口中,你会看到一个类似 Forwarding http://randomstring.ngrok.io -> localhost:3000 的消息。这个 ngrok 提供的 URL 就是你的本地服务器的公共访问地址。
      • 现在,你可以使用这个 ngrok 提供的 URL 来访问你的本地服务器,以便测试你的 Web 应用程序。
      notion image