Supporting the History API

But when we go to http://localhost:8200/register, we get a 404 Not Found response. From the terminal, we can see that this is because the request is handled by http-server, and not by our application:

"GET /register" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36""GET /register" Error (404): "Not found"

This makes sense because http-server is a very simple static server, whereas we want our routing done dynamically on the client. Therefore, we need to a use a server that supports this. pushstate-server is a static server that also works with HTML5 History API. Let's install it:

$ yarn add pushstate-server --dev

Now, in scripts/serve.sh, replace the http-server ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.