question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nest 6 and app.disable('x-powered-by')

See original GitHub issue

I’m submitting a…


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

With Nest 6, what is the proper way to disable the x-powered-by: Express header? It seems like disable(...) has been removed.

I don’t see any relevant information in the v6 documentation about this particular change.

What is the motivation / use case for changing the behavior?

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.disable('x-powered-by'); // no longer works
  app.use(nocache());
  await app.listen(1338);
}
bootstrap();

Environment


Nest version: 6.0.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
andreialecucommented, Mar 20, 2019

Thanks. I think the migration guide could use this information as well.

3reactions
kamilmysliwieccommented, Mar 20, 2019
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.disable('x-powered-by');

NestExpressApplication is imported from @nestjs/platform-express package. see https://docs.nestjs.com/first-steps#platform

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable X-Powered-By in nestjs does not work
If app.disable('x-powered-by') does not work, you can try/fix it with: app. ... then specify the app type in your NestFactory.create call.
Read more >
Getting rid of the X-Powered-By in Express JS Middle-ware ...
Completely removing the X-Powered-By headers ... First make sure which version of Express JS you are using right now. The reason being, different ......
Read more >
next.config.js: Disabling x-powered-by
Disabling x -powered-by. By default Next.js will add the x-powered-by header. To opt-out of it, open next.config.js and disable the poweredByHeader config:
Read more >
Nest × Yale Lock disconnected or offline
If you have a Nest x Yale Lock, your lock will go offline and become disconnected from Wi-Fi unless you use a Nest...
Read more >
Create-vercel-http-server-handler NPM | npm.io
server/app/app.module'; export const nestApplicationOptions: ... in NestExpressApplication if ('disable' in app) app.disable('x-powered-by'); return app; };.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found