【发布时间】:2017-12-29 04:28:42
【问题描述】:
我在我的项目中使用 React Router 4,当我直接在浏览器中输入 URL(如 localhost:8000/post/1)时,出现以下错误。
无法获取 /post/1
我在快递服务器上的代码是
app.get('/post/:id', function (req, res) {
res.sendFile('./public/index.html', {root: __dirname});
})
我尝试在react-router-dom 上使用{HashRouter} 包来允许哈希爆炸,但它似乎也不能正常工作。
如何解决此错误?并允许在我的项目中直接链接。谢谢
【问题讨论】:
标签: javascript node.js reactjs express react-router