节点js服务器。 http状态 - 404

Node js server. httpstatus - 404

我做了一个小服务器。当我尝试在浏览器中向我的服务器发出获取请求时,我可以看到正确的数据,但是当我尝试通过代码向我的服务器发出 post 请求时,我得到 httpstatus - 404。为什么会这样?

我的服务器代码:

var express = require('express');
var http = require('http');

var app = express();
app.get('/api/check', function(req, res) {
    res.send('{"debug": "on"}');
});
exports.app = functions.https.onRequest(app);

因为您的服务器没有 POST 路由请求处理程序。所以它显示 404 未找到消息。添加与 GET

相同的 POST 路由

您现在不接受对 API 的 POST 请求,仅接受 GET。要接受 POST 请求,请添加:

app.post("/api/example", function(req, res) {
    // do your logic here
}