Skip to content

Getting error "Headers is not defined" when calling Resend constructor (not backwards compatible from Node 18) #10

Open
@jbexx

Description

@jbexx

Im trying to setup Resend in an express project that is on Node version 17

Im on the latest version of Resend v2.0.0

When running the project I get an error saying:

"ReferenceError: Headers is not defined",
" at new Resend (/var/task/node_modules/resend/build/src/resend.js:34:28)",

The line referenced begins here:
... this.headers = new Headers({ Authorization: Bearer ${this.key}, 'User-Agent': userAgent, 'Content-Type': 'application/json', }); ...

where you're using the Headers interface of the fetch API. Unfortunately this is only supported in Node version 18 and greater. I don't think I saw anything in your documentation while getting setup that Node version 18 was a requirement. Will you ever offer some sort of backward compatibility?

When I clone this resend-express-example project I don't see this error, but it looks like the Resend version that gets downloaded is version 0.17.1 where the Headers interface isn't being used. What version was this implemented? Is it recommended that I roll back instead of waiting for support in the latest version?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions