node.js - firebase 服务后如何访问功能
问题描述
我正在使用 firebase 在我的机器上进行测试。在firebase serve
我只能使用 HTTP 访问功能之后:http://localhost:5001/project/us-central1/endpoint
但是,当我尝试获取参数时。
export const basicHTTP = functions.https.onRequest((req, res) => {
const name = req.params.name
res.send(`Hi, good! ${name}`)
})
我无法检索任何参数。我想我必须以 https 访问我的本地主机。
但是我的本地环境不提供通过 SSL 访问的方式。我该如何处理?
解决方案
模拟器使 HTTPS 云功能在本地主机上的 HTTPS和HTTP 上都可用。因此,您可以从代码中通过 HTTP 调用它。
从有关在模拟器中连接到 HTTPS 功能的文档中:
代码中的每个 HTTPS 函数都将使用以下 URL 格式从本地模拟器提供:
http://$HOST:$PORT/$PROJECT/$REGION/$NAME
例如,具有默认主机端口和区域的简单 helloWorld 函数将在以下位置提供服务:
https://localhost:5001/$PROJECT/us-central1/helloWorld
推荐阅读
- ios - Google Ad Mob 总是说“没有广告可展示”
- next.js - Next.js 服务器端登录 getServerSideProps 还是 api?
- linq - 通过 LINQ 获取层次结构中的所有子级
- ruby-on-rails - 更改文件夹时 rvm 没有选择正确的 ruby 和 gemset 版本
- bash - 使用 ansible 在 Openstack 中运行服务器后运行 shell 命令
- javascript - 为什么我的选择菜单的占位符没有使用 jquery 设置 setAttribute 选择器?
- php - Laravel Eloquent 收集方法不存在
- python - 在python中用Qt实现一个取消按钮
- powershell - 集成 Octopus 和 powershell
- javascript - Node.JS/Passport-CI-OIDC - 错误:发送后无法设置标头。在 ServerResponse.OutgoingMessage.setHeader