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.

res.setHeader is not a function When i add new FastifyAdapter()

See original GitHub issue

Describe the bug If i put new FastifyAdapter() like this const app = await NestFactory.create<NestFastifyApplication>( AppModule, new FastifyAdapter(), )

it will return error when i access localhost:3000

res.setHeader(“Cache-Control”, “no-cache, no-store, max-age=0, must-revalidate”); ^ TypeError: res.setHeader is not a function

Is it can’t support fastify adapter? Because i serve static files from my server use the fastify adapter

Version

  • next.js: 13.0.6
  • nest: 9.0.0
  • nest-next: 10.0.0

Issue Analytics

  • State:open
  • Created 9 months ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
samuelhalim1commented, Dec 12, 2022

TypeError: res.setHeader is not a function at NextNodeServer.renderError (/Users/Development/test/node_modules/.pnpm/next@13.0.6_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/base-server.js:1047:17) at NextNodeServer.renderError (/Users/Development/test/node_modules/.pnpm/next@13.0.6_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/next-server.js:844:22) at NextServer.renderError (/Users/Development/test/node_modules/.pnpm/next@13.0.6_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/next.js:115:23) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

1reaction
kyle-mccarthycommented, Dec 12, 2022

It works correctly with the fastify adapter. This library doesn’t actually make any calls to setHeader on the response, so I think that your problem is coming from your application code or perhaps nextjs. Whre does the stacktrace say that the setHeader call is?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js - "TypeError - res.setHeader is not a function"
Both post and getJSON callbacks have same res variable name. Try this: var getJSON =require('get-json'); app.post('/json', function(req, ...
Read more >
res.setHeader is not a function at FacebookStrategy.strategy ...
The issue here is that FastifyReply has a header method to set headers, but no setHeader like Express's Response . We can add...
Read more >
Facing Error res.setHeader not a Function - DEV Community ‍ ‍
Hello This is response from NodeJS>Server. ')//this method is used to display the response on the web page. res.end(). }).
Read more >
Cookies | NestJS - A progressive Node.js framework
Hint The @Res() decorator is imported from the @nestjs/common , while FastifyReply from the fastify package. Creating a custom decorator (cross-platform)#. To ...
Read more >
Node.js response.setHeader() Method - GeeksforGeeks
The response.setHeader(name, value) (Added in v0.4.0) method is an inbuilt application programming interface of the 'http' module which sets ...
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