Webpack-dev-server: Cannot GET URLs with extension with historyApiFallback: true

Created on 30 Nov 2015  路  5Comments  路  Source: webpack/webpack-dev-server

If I enter address like http://localhost:3000/foo everything works as expected, even http://localhost:3000/foo/bar/baz works too.

But addresses with extension http://localhost:3000/foo.html always return Cannot GET /foo.html.

Most helpful comment

I fixed it by adding the following to my webpack config (instead of historyApiFallback: true):

historyApiFallback: {
    rewrites: [
        {from: /.*\.html/, to: '/index.html'}
    ]
},

But I suspect this should be a default behavior...

All 5 comments

I fixed it by adding the following to my webpack config (instead of historyApiFallback: true):

historyApiFallback: {
    rewrites: [
        {from: /.*\.html/, to: '/index.html'}
    ]
},

But I suspect this should be a default behavior...

Thanks !!! it works !

I have the same issue one year later, thx @kirill-konshin for the solution.

Had the same issue with a route mapping like /item/:id where the id value just happened to contain a . sign.

However looks like webpack-dev-server just uses connect-history-api-fallback, that since 1.3.0 supports a disableDotRule option.

Still, not sure why it's not the default.

closing because this is not an issue in webpack-dev-server and there have been multiple answers.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tulika21-zz picture tulika21-zz  路  3Comments

uMaxmaxmaximus picture uMaxmaxmaximus  路  3Comments

wojtekmaj picture wojtekmaj  路  3Comments

mischkl picture mischkl  路  3Comments

hnqlvs picture hnqlvs  路  3Comments