fix: [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
See original GitHub issueHi all. When I have the following case, routing controllers fails and try to execute both functions:
@JsonController()
export class UserController {
@Get("/users/me")
getMe() {
const id = 1;
return userRepository.findById(id);
}
@Get("/users/:id")
getOne(@Param("id") id: number) {
return userRepository.findById(id);
}
}
As far as I read it should execute first occurency not both. Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Error: Can't set headers after they are sent to the client
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 >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 >Resolving HTTP Cannot set headers after they are sent ... - Fjolt
Node.JS will occassionally throw an error called ERR_HTTP_HEADERS_SENT, which can be tricky to resolve. Let's take a look at how to fix it....
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 >cannot set headers after they are sent to the client - You.com
This error occurs when you sent a response before and then you try to send response again. For this you have to check...
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 Free
Top 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
I have the same error. I use
routing-controller
in an existing express program. when I remove a middleware, it won’t throw again.id is a number so you can use regex to be stricter on the matching.