diff --git a/packages/vite/src/node/plugins/modulePreloadPolyfill.ts b/packages/vite/src/node/plugins/modulePreloadPolyfill.ts index 720566d40ad8e3..0f1ef11cf26f5e 100644 --- a/packages/vite/src/node/plugins/modulePreloadPolyfill.ts +++ b/packages/vite/src/node/plugins/modulePreloadPolyfill.ts @@ -78,13 +78,13 @@ function polyfill() { } }).observe(document, { childList: true, subtree: true }) - function getFetchOpts(script: any) { + function getFetchOpts(link: any) { const fetchOpts = {} as any - if (script.integrity) fetchOpts.integrity = script.integrity - if (script.referrerpolicy) fetchOpts.referrerPolicy = script.referrerpolicy - if (script.crossorigin === 'use-credentials') + if (link.integrity) fetchOpts.integrity = link.integrity + if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy + if (link.crossOrigin === 'use-credentials') fetchOpts.credentials = 'include' - else if (script.crossorigin === 'anonymous') fetchOpts.credentials = 'omit' + else if (link.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit' else fetchOpts.credentials = 'same-origin' return fetchOpts }