onError handler is not respecting content-type header
Author: EptagoneCreated Aug 14, 2026Updated Sep 24, 2026
Labelsbug
What version of Elysia is running?
What platform is your computer?
Darwin 25.5.0 arm64 arm
What environment are you using
Node v24.19.0
Are you using dynamic mode?
No
What steps can reproduce the bug?
Try to set the Content-Type header in the error method
app.onError(({ code, set }): ProblemDetails | void => {
if (code === "NOT_FOUND") {
set.headers["content-type"] = "application/problem+json";
return { status: 404, title: "Not Found" };
}
});What is the expected behavior?
The Content-Type header to be application/problem+json
What do you see instead?
The Content-Type header is application/json
Additional information
I'm trying to implement the Problem Details pattern (related #1902). It return errors as JSON with the content type application/problem+json. However, the onError handler is ignoring the value I set and using application/json instead
Have you try removing the node_modules and bun.lock and try again yet?
Yes
Source: elysiajs/elysia