## Web server configuration
-This demo website assumes that the web server has been configured to serve `index.html` on all routes **EXCEPT** for the special path: `/errors/404.html`. For `/errors/404.html`, the web server must respond with a `404 Not Found` error and the file `/errors/404.html`.
+This demo website assumes that the web server has been configured to serve `index.html` on all routes **EXCEPT** for the special path: `/errors/NotFound`. For `/errors/NotFound`, the web server must respond with a `404 Not Found` error and the file `/errors/404.html`.
-Note: this file path is intentionally nested in a folder because some static site hosts (like [Cloudflare Pages](https://developers.cloudflare.com/pages/platform/serving-pages)) use a top-level `404.html` page as a flag to override the desired behavior of serving `index.html` on all routes.
+Note: this file path is intentionally nested in a folder because some static site hosts (like [Cloudflare Pages](https://developers.cloudflare.com/pages/platform/serving-pages)) use a top-level `404.html` page as a flag to override the desired behavior of serving `index.html` on all other routes.
The desired behavior can be replicated locally using the npm package [local-web-server](https://www.npmjs.com/package/local-web-server):
```
-ws --spa index.html
+ws --spa index.html --rewrite '/errors/(.*) -> /errors/404.html'
```
if (!match) {
// MUST redirect to a page where the web server serves an actual 404 error (i.e. not just
// index.html again) otherwise this triggers an infinite loop
- window.location.href = `${window.location.protocol}//${window.location.host}/errors/404.html`;
+ window.location.href = `${window.location.protocol}//${window.location.host}/errors/NotFound`;
}
}