Alfred
Alfred

Reputation: 7091

How to redirect all traffic to the script ignoring folders with webpack-dev-server?

I have a SPA with pretty url navigation (/link instead of #link). It works fine as long as I start on the root and navigate around from there but if I go directly to /link in the browser I get Cannot GET /link.

How do I rewrite all requests to go to the main script file?

I've read through the webpack-dev-server docs but can't find anything.

Upvotes: -1

Views: 129

Answers (1)

Alfred
Alfred

Reputation: 7091

I found the answer, in webpack.config.json add the following:

devServer: {
  historyApiFallback: true
}

Upvotes: 0

Related Questions