🦅 Angular Universal with NestJS
Add server-side rendering to Angular with Nest.js
Create a server module using Angular Universal with the NestJS schematic.
Steps
Add Universal and Nest
command line
ng add @nestjs/ng-universal
npm run build:ssr
npm run serve:ssr
server/main.ts
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
app.setGlobalPrefix('api');
await app.listen(process.env.PORT || 8080); // <-- update this line
}
bootstrap();