如何通过Firebase Cloud Functions在本地运行Express API?

vbuzze

我有一个使用Express的标准REST API,通过Firebase Cloud Function公开。

const api = express()

api.get('/test', (req, res) => res.status(403).json({ "REASON": "UNAUTHORIZED" }))

exports.api = functions.https.onRequest(api)

远程

当我部署它并GET https://<remote>/api/test通过邮递员发送时,我得到403 { "REASON": "UNAUTHORIZED" }了预期的结果。

本地

当我运行firebase emulators:start --only functions本地服务这些功能并对其进行测试时,确实functions: HTTP trigger initialized at http://localhost:5001/.../api在终端中看到了,但是当我GET http://localhost:5001/.../api/test通过Postman发送时,我得到了200 Not Found

我想念什么吗?

vbuzze

这确实是Firebase CLI中的一个缺陷,似乎已在最新版本(7.13.1)中修复。

使用以下方法安装了最新版本: npm install -g firebase-tools@latest

注:它没有要求我更新到兼容版本firebase-functions,并firebase-admin为好。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Firebase Cloud Functions通过API密钥保护HTTPS端点

通过 Express API 从 Cloud Firestore 读取数据

如何通过cli / rest api / cloud函数运行Google Cloud Build触发器?

使用Firebase Cloud Functions(没有Express)创建Node.js REST API?

从Firebase Cloud Functions使用Slack的API dialog_open

Firebase Cloud Functions调用外部API时会引发DNS错误

如何使用Cloud Functions中的Cloud DataStore或Cloud SQL for Firebase?

如何通过Promise.all返回到另一个功能Firebase的Cloud Functions

如何创建通过Firebase Cloud Functions托管的Node.js代理服务器?

Firebase Cloud Functions运行Python脚本

Firebase Cloud Messaging HTTP V1 API:如何通过REST调用获取Auth 2.0访问令牌?

Firebase Cloud Messaging Statistics API

Firebase Cloud Functions 调用是如何计算的?

如何从Firebase Cloud Functions删除日志

Firebase的Cloud Functions:如何向我的Cloud Endpoint发出请求

Firebase Cloud Functions如何确认Cloud pub / sub

如何通过API获取Google Cloud Translation使用的字符?

如何保护通过GCP Cloud Run服务的REST API端点?

适用于Firebase的Cloud Functions中的本地依赖关系

我可以通过Firebase Cloud Functions实现聊天功能吗?

通过 Firebase Cloud Functions 访问 Firestore 时的流量路由

Firebase Cloud Messaging仅可从本地主机运行

如何通过 Firebase Cloud Functions 上的 .firebaserc 切换到另一个 serviceAccountKey.json?

尝试通过 Google Cloud Functions 托管此 Express 应用

由于Cloud Build API,Firebase Cloud Functions是否要求在2020年4月20日之前启用计费功能?

声明单独的Firebase Cloud Functions并仍使用Express.js

Firebase Cloud Functions + Express示例上的“无法获取”错误

如何在Cloud Functions for Firebase中读写Firebase存储?

如何通过Cloud Functions将文件上传到Cloud Storage并使用Firestore控制对Cloud Storage的访问?