Webpack Dev server setup for Angular html5mode

I am trying to enable html5mode in an Angular 1 application. This mode requires the web server to return the same HTML for different paths. In nginx, this is done by adding try ... index.html to the location , which means that nginx always returns to the main html if it cannot find the page.

However, during development, I do not have nginx, I use the Webpack dev server to serve the pages with the proxy server. How to configure Webpack dev server to behave in a similar way?

+6
source share
1 answer

Oh my God. Oh dear, dear, dear.

I looked through the documentation twice, and only after posting this question did I find the historyApiFallback settings, as described here.

Add this to your settings:

 devServer: { historyApiFallback: true, proxy: { ... } } 

I keep this question here, hoping this will help others save time in the future.

+6
source

Source: https://habr.com/ru/post/1015513/


All Articles