除了'/'

时间:2017-10-22 17:54:16

标签: javascript node.js express firebase

我无法处理GET或POST到根目录'/'以外的任何目的地。如果我尝试访问该路径,输出只是404错误,“无法GET / hello”。下面是我能想到的最简单的例子,但它仍然失败。我已经尝试使用路由器和app.use但是得到了同样的错误。

const functions = require('firebase-functions');
const firebase = require('firebase-admin');
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) => {
    console.log("This works");
    res.render(mytemplate, {});
});

app.get('/hello', (req, res) => {
    console.log("This is never logged");
    res.render(mytemplate, {}); //never happens
});

exports.app = functions.https.onRequest(app);

0 个答案:

没有答案