question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebpackDevServer breaks on complex nested routes

See original GitHub issue

Was running into this for a few days (on master & since upgrading to 3.0.0)

I had some routes like /releases /releases/:version

My :version param takes a semver number, like 1.2.3.

They work perfectly when navigating around the app using <Link /> etc, and /releases works when hard-refreshing the page, but hard refreshing on a url like localhost:3000/releases/1.2.3 returns an error like this: messages image 3763230329

I confirmed that it’s specifically having periods in paths that are broken (by adding a route handler on /releases/foo; finally managed to track it down to this issues. The fix proposed by stefanfisk works perfectly when I edited webpack/server.dev.js.

https://github.com/rackt/react-router/issues/676#issuecomment-73963306

I think this is a general enough problem to fix; it certainly shouldn’t be happening - do you want me to clean up the code and submit a PR to 3.0.0?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:28 (14 by maintainers)

github_iconTop GitHub Comments

89reactions
mxstbrcommented, Feb 6, 2016

Add the publicPath to your output option in your webpack config:

output: {
  path: path.resolve(__dirname, '..', 'build'),
  filename: '[name].js',
  chunkFilename: '[name].chunk.js',
  publicPath: '/'
}
3reactions
mxstbrcommented, Feb 6, 2016

I totally forgot you’re on master, the above solution would only work on v3.0.0! For master, please try this:

    output: { // Compile into js/build.js
      path: path.resolve(__dirname, 'build'),
      filename: "/js/bundle.js",
      publicPath: "/"
    },

Sorry for the unnecessary troubles!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Router v4 nested routes not work with webpack-dev ...
I finally figured out the reason that webpack-dev-server couldn't serve nested routes. As a single page application, when you visit ...
Read more >
React Router v4 — nested routes not work with webpack-dev ...
We built the route based on react-router in React, and tried to move ... React Router v4 — nested routes not work with...
Read more >
vue-routerのHistory モード+webpack-dev-serverでサブ ... - Qiita
vue-routerのHistory モード+webpack-dev-serverでサブディレクトリにアクセス ... 参考: WebpackDevServer breaks on complex nested routes #113.
Read more >
react-router - npm
Features · Nested views mapped to nested routes · Modular construction of route hierarchy · Sync and async transition hooks · Transition abort...
Read more >
Lazy loading React components - LogRocket Blog
Suspense; Named exports for React components; Route-based lazy loading in ... and break down how they facilitate lazy loading in React.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found