This improves the user experience by not sending the raw 404 back to the browser. However, this limits our application in that a user will not be able to refresh, bookmark, or share a link to anything other than the root of the SPA. Deep links will not work without additional setup.

Deep Links

The goal is to make it easy for users to navigate, find, and share content. For that, we need to enable deep linking in our SPA.

There are two distinct browser URL styles that our Angular application can employ: the default “natural” path, and hash-location. The Angular documentation has a good explanation of the differences between the two, and why you might choose one or the other. We’ll go through examples of both below.

Hash Style

One way to avoid the HTTP server not finding a resource is to just not request it. As the Angular documentation states:

Older browsers send page requests to the server when the location URL changes unless the change occurs after a “#” (called the “hash”).

We can make a request like: