首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在https而不是http上运行firebase (函数)模拟器?

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

Stack Overflow用户
提问于 2020-05-05 13:39:31
回答 1查看 1.6K关注 0票数 8

是否有人知道是否有一种方法可以用http 地址(而不是默认的地址)初始化Firebase函数(使用模拟器进行本地调试)?我试图调试一个电报,与机器人相关的脚本,电报只允许http网络钩子。

Shell输出如下:

代码语言:javascript
复制
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.

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

非常感谢您提前!

EN

回答 1

Stack Overflow用户

发布于 2021-05-21 16:37:35

就像评论中提到的@bermick一样,ngrok是一个很好的解决方法,直到Firebase给我们一种在本地模拟器上启用https的方法。以下是几个步骤:

ngrok二进制文件是一个免费的account.

  • Download ( ngrok二进制文件)(这是正常情况,他们让您download).

  • Open控制台/终端并导航到ngrok二进制文件所在的文件夹)。

  • Start中。如果还没有运行Firebase模拟器套件,那么请注意云函数正在运行的端口(如果您在谷歌上搜索如何在控制台中的emulator).

  • Back中使用https,我假设您知道如何这样做。确保您位于包含ngrok二进制文件的目录中,并运行此命令(用计算机的firebase函数模拟器端口替换5001 ) ./ngrok http 5001

  • Ngrok将打开一个UI,显示您可以点击的转发https url,它将转发到您的本地计算机。例如,通过使用ngrok转发url (请记住附加适当的云函数路径),Forwarding https://xxxxxxxxx.ngrok.io -> http://localhost:5001

  • Test退出云函数。例如https://xxxxxxxxx.ngrok.io/my-project/us-central1/cloudFunctionName
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61614571

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档