我有一个简单的firebase函数,它读取的数据量非常少(小于1kb),但是需要将近2秒才能完成并在日志中显示警告FIREBASE WARNING: Invalid query string segment:
结果是200 OK,但是显然有些奇怪的事情,
import express from 'express';
import * as functions from "firebase-functions"
const cors = require('cors')();
const api = express();
const getJob = async (req, res) => {
const { organisation, job } = req.params
console.log("READING", req.params)
console.log("one", `careers/jobs/${organisation}/${job}`)
const jobContent = await admin.database().ref(`careers/jobs/${organisation}/${job}`).once("value")
if (!jobContent) {
res.sendStatus(404)
}
console.log("two")
const descriptionContent =await admin.database().ref(`careers/descriptions/${organisation}/${job}`).once("value")
return res.send({
...jobContent.val(),
description: descriptionContent && descriptionContent.val()
})
}
api.use(cors);
api.get('/careers/:organisation/jobs/:job', getJob)
export const careersApi = functions.https.onRequest(api)
firebase.json
{
"functions": {
"source": "build"
},
"hosting": {
"public": "public",
"rewrites": [
{
"source": "/careers/**",
"function": "careersApi"
}
]
}
}