Search code examples
reactjswebpackreact-routerwebpack-dev-serverhtml5-history

Webpack Devserver HistoryApiFallback


I have my React webpack devserver set up like the following:

devServer: {
        port: 3000,
        historyApiFallback: true,
        proxy: {
            '/api': 'http://localhost:8080'
        }
    },

Now I also need to add disabledDotRule: true to the historyApiFallback. Can someone help me to do that? If I try just to change it to

historyApiFallback: {
            disableDotRule: true,
        },

I get the following ECONNREFUSED error:

Error occurred while trying to proxy request /api/.../ from localhost:3000 to http://localhost:8080

I guess the problem is that historyApiFallback: true is missing. How do I keep that while also adding disabledDotRule: true?


Solution

  • Apologies, I misunderstood your question.

    Could you try the following things and see if any work:

    (1) Replace "http:localhost:8080" with "http://[::1]:8080" like so:

    proxy:{
      "/api":"http://[::1]:8080"
    }
    

    (2) Run the API on a different port like 8081 and see if you get the same error