ERROR: Cannot set headers after they are sent to the client : Cannot set headers after they are sent to the client
See original GitHub issueHello 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:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
Also getting this error systematically when trying to implement server-sent events in a fresh Nuxt3 project.