【发布时间】:2020-08-18 07:17:36
【问题描述】:
我正在尝试使用 node 和 firebase 创建我的后端服务器,但是当我尝试从中获取数据时出现错误:“net::ERR_SSL_PROTOCOL_ERROR”。 我的 firebase/functions/index.js 文件是
const functions = require("firebase-functions");
const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.send("hello firebase");
});
exports.app = functions.https.onRequest(app);
在 VSCode liveServer 的 5500 端口上运行的 index.html 只是主体标签中带有 <script>fetch('https://localhost:5000').then(res=>res.text()).then(res=>console.log(res));</script> 的 emmet 骨架。最后,firebase.json 是
{
"functions": {
"predeploy": ["npm --prefix \"$RESOURCE_DIR\" run lint"]
},
"hosting": {
"rewrites": [
{
"source": "/",
"function": "app"
}
],
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
}
}
我想值得一提的是,当我在浏览器中访问 localhost:5000 时,我得到了预期的“hello firebase”
@edit:我设置了纯快递服务器,bahaiviour 没有变化。
【问题讨论】:
标签: javascript node.js firebase google-cloud-functions firebase-hosting