Skip to content

Commit db487cf

Browse files
authored
refactor: Provide original, unpatched fetch impl on globalThis (#140)
1 parent fcac66b commit db487cf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/prerender.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ export function PrerenderPlugin({
177177
globalThis.__VITE_PRELOAD__ = [];
178178

179179
// Local, fs-based fetch implementation for prerendering
180-
const nodeFetch = globalThis.fetch;
180+
// @ts-ignore
181+
globalThis.unpatchedFetch = globalThis.fetch;
181182
// @ts-ignore
182183
globalThis.fetch = async (url: string, opts: RequestInit | undefined) => {
183184
if (/^\//.test(url)) {
@@ -197,7 +198,8 @@ export function PrerenderPlugin({
197198
}
198199
}
199200

200-
return nodeFetch(url, opts);
201+
// @ts-ignore
202+
return globalThis.unpatchedFetch(url, opts);
201203
};
202204

203205
// Grab the generated HTML file, which we'll use as a template:

0 commit comments

Comments
 (0)