diff --git a/apps/web/jest.config.js b/apps/web/jest.config.js index 8903f9b6e34..6ddc5f16793 100644 --- a/apps/web/jest.config.js +++ b/apps/web/jest.config.js @@ -27,7 +27,7 @@ module.exports = async () => { ...nextJestConfig, transformIgnorePatterns: [ // Transform all node_modules except the ones below - 'node_modules/(?!(.*\\.mjs$|@coinbase/onchainkit|wagmi|@wagmi|viem|node-fetch|data-uri-to-buffer|fetch-blob|formdata-polyfill|graphql-request|cross-fetch|is-ipfs|uint8arrays|multiformats|@multiformats|iso-url))', + 'node_modules/(?!(.*\\.mjs$|@coinbase/onchainkit|wagmi|@wagmi|viem|node-fetch|whatwg-fetch|data-uri-to-buffer|fetch-blob|formdata-polyfill|graphql-request|cross-fetch|is-ipfs|uint8arrays|multiformats|@multiformats|iso-url))', ], }; }; diff --git a/apps/web/package.json b/apps/web/package.json index 97c055e759c..dfb4fd64504 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -99,6 +99,7 @@ "uuid": "^10.0.0", "viem": "2.x", "wagmi": "2.17.5", + "whatwg-fetch": "^3.6.20", "zustand": "^5.0.5" }, "devDependencies": { diff --git a/apps/web/scripts/helpers/fetchPolyfill.js b/apps/web/scripts/helpers/fetchPolyfill.js index d1bb1037e61..6a1d7584e23 100644 --- a/apps/web/scripts/helpers/fetchPolyfill.js +++ b/apps/web/scripts/helpers/fetchPolyfill.js @@ -1,11 +1,3 @@ // fetch-polyfill.js -function fetch(...args) { - return import('node-fetch').then(({ default: _fetch }) => _fetch(...args)); -} - -if (!globalThis.fetch) { - globalThis.fetch = fetch; - globalThis.Headers = fetch.Headers; - globalThis.Request = fetch.Request; - globalThis.Response = fetch.Response; -} +// Polyfill fetch for Node.js environments using whatwg-fetch +require('whatwg-fetch'); diff --git a/apps/web/src/cdp/utils.ts b/apps/web/src/cdp/utils.ts index bc6c5f12c71..c2a078a0a52 100644 --- a/apps/web/src/cdp/utils.ts +++ b/apps/web/src/cdp/utils.ts @@ -1,6 +1,5 @@ import { cdpBaseUri } from 'apps/web/src/cdp/constants'; import { generateCdpJwt } from 'apps/web/src/cdp/jwt'; -import { Response } from 'node-fetch'; export async function cdpGet(endpoint: string, authed: boolean): Promise { const headers = new Headers(); diff --git a/yarn.lock b/yarn.lock index 91d0bfb3572..ac8f2e40db3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -213,6 +213,7 @@ __metadata: uuid: ^10.0.0 viem: 2.x wagmi: 2.17.5 + whatwg-fetch: ^3.6.20 zustand: ^5.0.5 languageName: unknown linkType: soft @@ -23382,7 +23383,7 @@ __metadata: languageName: node linkType: hard -"whatwg-fetch@npm:^3.4.1": +"whatwg-fetch@npm:^3.4.1, whatwg-fetch@npm:^3.6.20": version: 3.6.20 resolution: "whatwg-fetch@npm:3.6.20" checksum: c58851ea2c4efe5c2235f13450f426824cf0253c1d45da28f45900290ae602a20aff2ab43346f16ec58917d5562e159cd691efa368354b2e82918c2146a519c5