February 2019
Beginner
694 pages
18h 4m
English
In a nutshell, then, to serve an Angular application from an http server, we really just need to serve up the index.html file that is in the dist directory. Ideally, this index.html file will be in the base directory of the http server, so that it will be the default file if none is specified. Let's set up an Express server to accomplish this.
Firstly, we will create an express directory, and a main.ts file within this directory that will contain our Express server code. The express/main.ts file is as follows:
import express from 'express'; import path from 'path'; let app = express(); app.use(`/`, express.static(__dirname + '/angular-sample')); app.get(`*`, (req: any, res: any) => { res.status(200).sendFile( path.join(__dirname ...Read now
Unlock full access