首页 > 解决方案 > 如何在本地测试firebase云功能express webserver更改

问题描述

我正在使用 Firebase 编写一个快速网络服务器。但是,似乎我无法在本地测试我的更改。

我正在尝试按照文档在本地测试云功能。但是当我在本地进行更改时,只会执行部署的版本,而不是本地版本。

在两个单独的外壳中,我正在运行:

firebase emulators:start --only functionsfirebase serve --only hosting

这是/functions/index.js

const functions = require('firebase-functions');
const express = require('express');
const app = express();

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

app.get('/myroute', (req, res) => {
    return res.send('hello1');
});

module.exports = {
    app: functions.https.onRequest(app),
};

当我将 'hello1' 修改为 'hello2',然后保存,重新启动两个服务器,并localhost:5000/myroute在我的浏览器中请求时,它仍然以hello1.

当我请求时,如何让我的本地云功能更改出现localhost:5000/myroute

标签: firebasegoogle-cloud-functionsfirebase-cli

解决方案


推荐阅读