嗨,当我部署我的firebase web应用程序时,我在访问端点时遇到404 not found错误。
下面是我的src/routes/functions文件夹中的index.js文件的一部分。
const port = process.env.PORT || 80;
server.listen(port,'127.0.0.1');
console.debug('Server listening on port ' + port);
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "*",
authDomain: "*",
databaseURL: "*",
projectId: "*",
storageBucket: "*",
messagingSenderId: "93371481008",
appId: "*",
measurementId: "G-NR8N5HP6RZ"
};
// Initialize Firebase
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}else {
firebase.app(); // if already initialized, use that one
}
router.get('/test', function(req,res){
console.log("router map test");
res.send("test page");
});
字符串
当我通过键入sudo firebase deploy
来部署Firebase Web应用程序时,
当我尝试访问index. js-curl -X GET https://PROJECT_ID/test
中的测试端点时,我得到了一个404错误。
下面是我的firebase.json文件:
"hosting": {
"public": "src/main/www",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},```
"functions": [
{
"source": "src/routes/functions",
"codebase": "map-print",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
]
}
],
"rewrites": [
{
"source": "/test",
"function": "test"
}
]
}
型
1条答案
按热度按时间fzsnzjdm1#
您缺少导出函数本身。
我假设你使用
express
来处理你的路由,所以这里有一个最小的例子:字符串