BrowserHistory(react-router v4)返回404并且historyApiFallback不起作用 .
所以,当我去http://localhost:3000/app时,我得到了404.我尝试了以下解决方案但没有任何结果......任何想法?我也尝试将historyApiFallback设置为true而不使用bundle.js的相对路径,即index.html中的/static/bundle.js
historyApiFallback doesn't work in Webpack dev server historyApiFallback doesn't work, for scripts, if you're nested multiple path sections deep
Index.html
`<script src="bundle.js"></script`>
Webpack output
output: {
path: path.join(__dirname, 'public'),
filename: 'bundle.js',
publicPath: '/'
},
Webpack devServer
historyApiFallback: { index: 'public/index.html' },
1 回答
令人尴尬的是,我没有正确设置我的Express服务器路由 . 我使用了基于HashRouter的教程中的相同设置....
我将以下内容添加到我的server.js并且它有效!