所以我只是试图运行一个firebase应用程序,当在本地运行时,我从chrome控制台收到错误:GET http://localhost:5000/behaviors/signup.js net::ERR_ABORTED 404 (Not Found)
我觉得我必须在重写时设置firebase.json源和目标,或者在index.js中为它添加一个路由?
index.hbs:
<script type="text/javascript" src="../behaviors/signup.js"></script>
index.js:
const functions = require('firebase-functions');
const express = require('express');
const engines = require('consolidate');
const app = express();
app.engine('hbs', engines.handlebars);
app.set('views', './views');
app.set('view engine', 'hbs');
app.get('/', (req, res) => {
res.render("index");
});
exports.app = functions.https.onRequest(app);
firebase.json:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [{
"source": "/",
"function": "app"
}]
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
],
"source": "functions"
}
}
app.use(express.static( '公共')); //提供静态文件