Skip to content

onError handler is not respecting content-type header #1964

Description

@Eptagone

What version of Elysia is running?

elysia@1.4.29

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions