Please assist i have a angular 8 nestJs application, i am using angular universal @nestjs/ng-universal
to render both applications as one. I then notice a more than 5 second delay/waiting(TTFB). When i ng serve
the angular part is quick(about 3ms). Saw the following Angular Universal TTFB is very slow but doesnt help me much. looking at the browser logs i see the following below:
[Violation] 'load' handler took 347ms
Can i add something to Nest to reduce TTFB, I didn't add any setTimeout to the code so i don't understand why it takes 5sec not less. my main.ts is as follows :
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
app.setGlobalPrefix('api');
const options = new DocumentBuilder()
.setTitle('Cars API V1')
.setDescription('Cars API')
.setVersion('1.0')
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('swagger', app, document);
await app.listen(4200);
}
bootstrap();
My nestJS app module is as follows:
@Module({
imports: [
SharedModule,
HttpModule,
AngularUniversalModule.forRoot({
cache: false,
viewsPath: BROWSER_DIR,
bundle: require('../server/main')
}),
ConfigModule.forRoot({
isGlobal: true
}),
],
controllers: [AppController,],
providers: [AppService]
})
export class ApplicationModule {}