如何在 https 而不是 http 上运行 firebase(函数)模拟器?

Mar*_*arc 5 firebase telegram-bot google-cloud-functions telegram-webhook firebase-cli

会有人知道,如果有一种方法来初始化一个火力地堡功能(使用仿真器来调试本地)与HTTP小号地址,而不是默认的HTTP?我正在尝试调试与 Telegram bot 相关的脚本,而 Telegram 只允许 httpwebhook。

外壳输出如下:

PS C:\Users\<user>\Desktop\tmp_node\functions> firebase emulators:start --only functions
i  emulators: Starting emulators: functions
+  hub: emulator hub started at http://localhost:4400
+  functions: Using node@10 from host.
+  functions: functions emulator started at http://localhost:8443
i  functions: Watching "C:\Users\<user>\Desktop\tmp_node\functions" for Cloud Functions...
+  functions[<function name>]: http function initialized (http://localhost:8443/<endpoint>).
+  emulators: All emulators started, it is now safe to connect.
Run Code Online (Sandbox Code Playgroud)

我需要它从 http s ://localhost:8443/ 开始。

非常感谢您提前!

Tre*_*v14 1

就像@bermick 在评论中提到的那样,ngrok是解决这个问题的好方法,直到 Firebase 人员为我们提供了一种在本地模拟器上启用 https 的方法。步骤如下:

  1. 前往https://ngrok.com并注册一个免费帐户。
  2. 下载 ngrok 二进制文件(这是他们让您下载的正常内容)。
  3. 打开控制台/终端并导航到 ngrok 二进制文件所在的文件夹。
  4. 通过运行此命令并放入您的身份验证令牌来设置您的身份验证令牌: ( https://dashboard.ngrok.com/get-started/setup./ngrok authtoken [[your_token]]的当前页面将包含包括令牌的整个命令,因此您只需复制并将其粘贴到控制台中)。
  5. 如果 Firebase 模拟器套件尚未运行,请启动它,并记下运行云功能的端口(如果您正在谷歌搜索如何在模拟器中使用 https,我假设您知道如何执行此操作)。
  6. 返回控制台,确保您位于包含 ngrok 二进制文件的目录中并运行此命令(将 5001 替换为您计算机的 firebase 功能模拟器端口)./ngrok http 5001
  7. Ngrok 将打开一个 UI,显示您可以点击的转发 https url,该 URL 将转发到您的本地计算机。例如Forwarding https://xxxxxxxxx.ngrok.io -> http://localhost:5001
  8. 使用ngrok https转发url测试云函数(记住附加适当的云函数路径)。例如https://xxxxxxxxx.ngrok.io/my-project/us-central1/cloudFunctionName