Skip to content

getHeaders is undefined error in Cloudflare Workers #69

@mitchellsimoens

Description

@mitchellsimoens

I was implementing this for use in a Cloudflare Worker. For local dev, I was using wrangler. For some reason, I was getting a w.getHeaders is undefined. I traced it down to this block of code:

jwt-auth/index.js

Lines 96 to 105 in 9cd947f

const form = new FormData();
form.append('client_id', clientId);
form.append('client_secret', clientSecret);
form.append('jwt_token', token);
const postOptions = {
method: 'POST',
body: form,
headers: form.getHeaders()
};

I'm wondering if it's because of const FormData = require('form-data'); where FormData is being the JavaScript FormData and not the form-data version as the JavaScript class doesn't have a getHeaders function.

Some debugging I did was added a console.log(form.getHeaders); and that logged out undefined as expected so it's certainly not the form-data one.

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