-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove node-fetch
#11266
Remove node-fetch
#11266
Conversation
This reverts commit 7d122f4.
node-fetch
""node-fetch
const BFF_IS_LOCAL = | ||
process.env.JEST_WORKER_ID === undefined && | ||
process?.env?.BFF_PATH?.includes('localhost:3210'); | ||
const BFF_IS_LOCAL = process?.env?.BFF_PATH?.includes('localhost:3210'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this now be removed? BFF_IS_LOCAL
is used in an if statement below to determine whether to add optional headers or not, but wondering if we could use certsRequired
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the logic now to try and make it a bit simpler, inline with your suggestion. a32bff8
It has changed the value of the headers when running locally, but I tested this with the BFF running on the Test env and with the BFF running locally as well and it seems fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple more commits to get it working, but think its a bit better? Not sure of the need of the accept
header locally, so its removed.
This reverts commit df4043e.
Reverts #11261 and reinstates the original PR: #11122
Description from original PR:
Overall changes
Removes
node-fetch
andisomorphic-fetch
in favour of using Node 18+ built-in fetch mechanism, provided byundici
. Removes the need to do #9611undici
has been added as a dependency as we need itsAgent
constructor to use our custom certs to authenticate requests.This aligns the Express and Next.js app to use the same fetch mechanism across both apps, and removes the need to keep
node-fetch
updated through its transition to ESM.Code changes
node-fetch
andisomorphic-fetch
and the instances these libraries were importedgetAgent
function across the Express and Next.js appsAgent
andgetAgent
in testsfetchDataFromBFF
Testing
yarn
to install the new dependenciesyarn dev
renderer_env=live
flag to ensure it fetches Live data with the certs