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.

ERROR: Cannot set headers after they are sent to the client : Cannot set headers after they are sent to the client

See original GitHub issue

Hello I made nuxt-nitro demo clone without nitro. URL is here. https://nuxt-without-nitro-demo.vercel.app/

I try with /api/hello made with h3, It failed after deploy. When I test on local, It make error.

 ERROR  Cannot set headers after they are sent to the client                                                                                                              20:39:12

  at ServerResponse.setHeader (_http_outgoing.js:518:11)
  at sendError (node_modules/h3/dist/index.js:502:7)
  at node_modules/h3/dist/index.js:514:14

My server middleware is https://github.com/ChangJoo-Park/nuxt-without-nitro-demo/blob/main/server/hello.js#L4-L8. I tested with remove res.setHeader('Access-Control-Allow-Origin', '*') . but it fails too.

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
ChangJoo-Parkcommented, Mar 16, 2021

Thank you for reply, @danielroe ! I’ll make repo without Nuxt.

Here you are. https://github.com/ChangJoo-Park/h3-issue-21/

It is not happen. It seems to have occurred because of h3 with Nuxt.

I met this error https://github.com/ChangJoo-Park/nuxt-without-nitro-demo/blob/65786ca495f8a24939451923ddaa0f7ebf54f125/server/hello.js#L1-L8 . Using h3 with Nuxt

1reaction
lewebsimplecommented, Mar 30, 2022

Also getting this error systematically when trying to implement server-sent events in a fresh Nuxt3 project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot set headers after they are sent to the client in JS
The "Cannot set headers after they are sent to the client" error occurs when the server in an express.js application sends more than...
Read more >
Cannot set headers after they are sent to the client | End Your If
Why am I receiving the error message can't set headers after they are sent to the client Nodejs? · Calling the request handler...
Read more >
“Can't set headers after they are sent to the client” error in ...
The error “Error: Can't set headers after they are sent.” means that you're already in the Body or Finished state, but some function...
Read more >
Resolving HTTP Cannot set headers after they are sent ... - Fjolt
This is quite a confusing error if you aren't familiar with HTTP headers. This error arises when you send more than 1 responses...
Read more >
Error [err_http_headers_sent]: cannot set headers after they ...
The error "Error: Can't set headers after they are sent." means that you're already in the Body or Finished state, but some function...
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