我想为路线“/ about”提供另一个静态页面, 现在我有:
app.use(express.static(path.resolve(__dirname, '..', 'build')));
app.get('/', (req, res) => {
res.sendFile(path.resolve(__dirname, '..', 'build', 'index.html'));
});
app.get('/about', function (req, res) {
console.log("here")
res.sendFile(path.resolve(__dirname, '..', 'build', 'about.html'));
});
我还有一个帖子请求
app.post('/getfrontpage', (req, res) => {
console.log("FIRST PAGE", req.body.params.page)
});
帖子请求有效,我使用axios拨打电话,但是当我更改网址时“/ about”路由不起作用
答案 0 :(得分:0)
服务器端是否有任何错误?
以上示例适用于我:https://runkit.com/dionnis/5ab936152f32d7001211d85f
注意:我将app.post('/getfrontpage'
更改为app.get('/getfrontpage'