javascriptangularjsroute-provider

AngularJs cannot get route with dot in url on localhost


Using route provider and having this route set:

.when('/:name/:id', {

It works (enters on my route and execute the code) when I use:

https://localhost.myapp.com:9000/Paul/123

But it does not work using this url:

https://localhost.myapp.com:9000/Paul/123.456

But my id = 123.456 so I need to use the second scenario and I get error "Cannot GET ..." so I believe that the dot is the issue.

If I check the network tab it I see that the browser interprets 123.456 like a file for example readme.txt it thinks that the chars after the dot is the extension of the file.

Strange thing is that on production it works.

Any ideea on how to fix this ?


Solution

  • I have managed to find an answer to this issue. It was related to webpack which was present only on my localhost and not in production (this explains why I had this issue only on localhost).

    I had to add this setting in webpack config file webpack.dev.js under devServer section:

    historyApiFallback: {
        disableDotRule: true
    }