Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling auto-generated etags in NestJs app

Tags:

express

nestjs

How can I disable auto-generated Etags in Nestjs? It's based on Express, so there something like

expressApp.set('etag', false);

should do the trick.

How can I access express app from NestJs main?

like image 585
Marc Stroebel Avatar asked Nov 15 '25 13:11

Marc Stroebel


1 Answers

You can drop down to the express adapter using getHttpAdapter(), so you can do something like

const bootstrap = async () => {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  app.getHttpAdapter().getInstance().set('etag', false);
  await app.listen(3000);
}

Docs on HttpAdapter here

Thanks rodorgas for the .getInstance() addition

like image 81
Jay McDoniel Avatar answered Nov 18 '25 19:11

Jay McDoniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!