Skip to content

Content-Type header only works with ctx.body() #3908

Open
@LoryPelli

Description

@LoryPelli

What version of Hono are you using?

4.7.0

What runtime/platform is your app running on? (with version if possible)

Cloudflare Workers

What steps can reproduce the bug?

The following code DOESN'T work

ctx.text(await res.text(), {
        headers: {
            'Content-Type': 'text/javascript',
        },
});

The following code DOES work

ctx.body(await res.text(), {
        headers: {
            'Content-Type': 'text/javascript',
        },
});

You should make text function (but probably also json and others) to omit Content-Type header from his typescript type...

What is the expected behavior?

if it doesn't work typescript should complain (also javascript because you shouldn't be able to do a thing like this at all)

What do you see instead?

no error but wrong Content-Type (text/plain in my case)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions