Skip to content

Commit

Permalink
Fix consumption from Next.js client components (#464)
Browse files Browse the repository at this point in the history
Apparently, `process` exists but `.versions.node` does not. Next.js may
be doing something weird with `process` so we'll just be more cautious
when testing for Node.js v18 in the `fetch` polyfill.
  • Loading branch information
wKovacs64 committed Apr 29, 2024
1 parent b2901eb commit 1dd6547
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/olive-pandas-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'hibp': patch
---

Fix consumption from Next.js client components.
3 changes: 2 additions & 1 deletion src/api/fetch-polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable global-require */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */

// This can probably be removed in favor of Node's native fetch once we drop
// support for v18. https://x.com/ebey_jacob/status/1709975146939973909?s=20
Expand All @@ -9,7 +10,7 @@
export function installUndiciOnNode18() {
if (
typeof process !== 'undefined' &&
process.versions.node.startsWith('18.')
process.versions?.node?.startsWith('18.')
) {
const {
File: UndiciFile,
Expand Down

0 comments on commit 1dd6547

Please sign in to comment.