Skip to content

πŸ› Bug Report β€” URLSearchParams body sets incorrect fetch content-typeΒ #3066

@nickbabcock

Description

@nickbabcock
export default {
    async fetch(request, env, ctx) {
        const r = new Request('https://example.com/', {
            method: 'POST',
            body: new URLSearchParams({ hello: 'world' })
        });
        return new Response(r.headers.get('content-type'))
    },
};

Expected (ref):

application/x-www-form-urlencoded;charset=UTF-8

Actual:

text/plain;charset=UTF-8

This behavior differs from browsers and node.js

Replicated in cloudflare workers playground and in a production workers deployment.

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