Skip to content

Commit b4f2906

Browse files
JakeChampionpieh
andauthored
fix(v4): make fetch and self both be reassignable instead of const (#3360)
Co-authored-by: pieh <[email protected]>
1 parent 593e4e0 commit b4f2906

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@
139139
"demos/next-export",
140140
"demos/base-path",
141141
"demos/plugin-wrapper",
142-
"demos/server-components",
143142
"demos/middleware",
144143
"demos/custom-routes",
145144
"demos/next-with-edge-functions"

packages/runtime/src/templates/edge/shims.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ if (!('getAll' in Headers.prototype)) {
3737
}
3838
// Next uses blob: urls to refer to local assets, so we need to intercept these
3939
const _fetch = globalThis.fetch
40-
const fetch /* type {typeof globalThis.fetch} */ = async (url, init) => {
40+
/* type {typeof globalThis.fetch} */
41+
globalThis.fetch = async function fetch (url, init) {
4142
try {
4243
if (url instanceof URL && url.href?.startsWith('blob:')) {
4344
const key = url.href.slice(5)
@@ -74,4 +75,4 @@ if (typeof require === 'undefined') {
7475

7576
// Next edge runtime uses "self" as a function-scoped global-like object, but some of the older polyfills expect it to equal globalThis
7677
// See https://nextjs.org/docs/basic-features/supported-browsers-features#polyfills
77-
const self = { ...globalThis, fetch }
78+
globalThis.self = { ...globalThis, fetch }

0 commit comments

Comments
 (0)