Complete the code to enable server-side rendering in an Angular app.
import { [1] } from '@angular/platform-server';
The ServerModule is imported from '@angular/platform-server' to enable server-side rendering in Angular.
Complete the code to bootstrap the Angular app with server-side rendering.
platformServer().bootstrapModule([1]);The AppServerModule is the Angular module configured for server-side rendering and should be bootstrapped on the server.
Fix the error in the Angular Universal server main file to correctly import the server module.
import { [1] } from './app/app.server.module';
The correct import for the server main file is AppServerModule from the server module file.
Fill both blanks to create a simple Angular Universal express server that handles requests.
import * as express from 'express'; import { ngExpressEngine } from '@nguniversal/express-engine'; import { [1] } from './src/main.server'; const app = express(); app.engine('html', ngExpressEngine({ bootstrap: [2] }));
Both blanks should be AppServerModule to correctly set up the Angular Universal express engine.
Fill all three blanks to complete the Angular Universal server setup with rendering and static file serving.
app.get('*.*', express.static('[1]', { maxAge: '[2]' })); app.get('*', (req, res) => { res.render('index', { req, providers: [ { provide: '[3]', useValue: req } ] }); });
The static files are served from dist/browser with a cache max age of 1y. The Angular Universal server injects the REQUEST token for the current request.