Skip to content

fetch: duplicate Content-Type header sent when -b (JSON body) and -H content-type are both passed #47

Description

@rolznz

When using @getalby/cli fetch with a JSON -b body and an explicit -H '{"content-type":"application/json"}', the CLI sends a duplicated
header:

content-type: application/json, application/json

The CLI appears to set content-type: application/json automatically for a JSON body, and then appends the user-provided -H value instead of
replacing/deduping it.

Why it matters: some servers (e.g. anything built on Fastify) can't parse the comma-joined media type and reject the request with 415
Unsupported Media Type before it reaches any handler. The same request succeeds when -H is omitted.

Expected: the CLI should send a single content-type value — a user-supplied -H header should override/replace the auto-added default, not be appended to it (and ideally dedupe headers in general).

Workaround: omit -H content-type when the body is already JSON.

Env: @getalby/cli (latest via npx), Node v22.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions