11

I'm trying to enable html5mode in an Angular 1 application. This mode requires the webserver to return the same HTML for various paths. In nginx, this is done by adding a try ... index.html for the location, meaning nginx always fails back to the main html if it can't find the page.

However, while development I have no nginx, I'm using the Webpack dev server to serve the pages, with a proxy to the backend. How do I configure the Webpack dev server to behave in a similar fashion?

1 Answer 1

15

Oh dear. Oh dear oh dear oh dear.

I scanned the documentation twice, and only after posting this question I found the historyApiFallback settings, as described here.

Add this to the settings:

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

I'm keeping this question here hoping it will help others save time in the future.

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome :D I checked github.com/angular-ui/ui-router/wiki/… but there is no option for webpack-dev-server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.