繁体   English   中英

弹出的create-react-app的快速路由

[英]Express Routes for ejected create-react-app

我想为“ / 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”路由不起作用

您在服务器端是否有任何错误?

上面的示例对我有用https : //runkit.com/dionnis/5ab936152f32d7001211d85f

注意:我将app.post('/getfrontpage'更改为app.get('/getfrontpage'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM