`getHeaders` is undefined error in Cloudflare Workers
- Dominant language
- JavaScript
- Stars
- 17
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
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:
https://github.com/adobe/jwt-auth/blob/9cd947f720a11ac67a601bcb6988a3b702617d47/index.js#L96-L105
I'm wondering if it's because of `const FormData = require('form-data');` where `FormData` is being the [JavaScript `FormData`](https://developer.mozilla.org/en-US/docs/Web/API/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.
Contributor guide
Research direction
Start with index.js lines 96-105 and reproduce the issue in a Cloudflare Worker using Wrangler. Inspect the FormData import and the logged form.getHeaders value; done means the Worker no longer encounters an undefined getHeaders error during the affected flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100