In my react app I'm using react-router with BrowserRouter
. my webpack file has
devServer.historyApiFallback: true
I have a
<Route path='/details/:parameter' />
when navigating through the app, both the fallback and the route(s) work as expected.
However, if I'm on the route that serves at /details/:parameter
and I refresh, the app breaks and tells me in the console that it can't find
/details/webpack_bundle.js
however the url in the browser still contains the correct route with its parameter.
I was hoping to find an elegant solution to this. Any explanation for why it's behaving this way is appreciated.
duplicate question: see React nested route fails to load on refresh.
I'm using HTML Webpack Plugin in webpack and this is the solution I found.
webpackConfig.output.publicPath = '/'
this loads the bundle from the root directory.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加