Serving an Angular web application with Express
Single-page-applications (SPAs) are generally built into a collection of static assets that can be served through any web server without any need for an application state or routing behind it. However, in production environments, we often will need to provide routing configuration to compose SPA content with application services from our application's backend. Luckily, Express offers excellent built-in support for working with static assets and configuring them within our web server.
Getting ready
Let's set up our Express web server to serve our Angular application's files. We want our Angular app to be served on the same domain as our web server's API, while still being able to access our API endpoints for when we eventually have services for our Angular application to use.
How to do it...
This section covers how to implement static file serving in Express.
- First, let's build our Angular application by running the Angular-CLI
build
command in our...