首页 > 解决方案 > 当我在浏览器中运行 firebase 功能时,出现 403 错误

问题描述

当我从 url 运行 firebase 函数时,我收到了这个错误:Your client does not have permission to get URL /testing from this server.谁能帮我,为什么我会收到这个错误?在这里我添加了我的代码

这是我的代码

const express = require('express');
const app = express();
const cors = require('cors');
app.use(cors({ origin: true }));

app.get('/testing', (req, res) => {
  res.send({ 'status': 0});
});
exports.widgets = functions.https.onRequest(app);

标签: node.jsfirebaseexpressgoogle-cloud-functions

解决方案


当您导出 HTTP 类型函数时,函数的名称将成为 URL 的一部分。您可能希望使用路径/widgets/testing来调用您的快速路由,因为“小部件”是函数的名称。


推荐阅读