Skip to content

fix(lazy-dynamic): pass crossOrigin to preload call for next/dynamic chunks#92913

Closed
aphrody-code wants to merge 1 commit intovercel:canaryfrom
aphrody-code:fix/lazy-dynamic-crossorigin
Closed

fix(lazy-dynamic): pass crossOrigin to preload call for next/dynamic chunks#92913
aphrody-code wants to merge 1 commit intovercel:canaryfrom
aphrody-code:fix/lazy-dynamic-crossorigin

Conversation

@aphrody-code
Copy link
Copy Markdown

Summary

When assetPrefix and crossOrigin are configured in next.config.js, the ReactDOM.preload() call for next/dynamic scripts was missing the crossOrigin option, causing CORS warnings in Chrome when assets are served from a different domain.

Fix

Use process.env.__NEXT_CROSS_ORIGIN (the same env variable used by the client-side route-loader) to pass the configured crossOrigin value to preload(), consistent with how other parts of Next.js handle this.

Fixes #92797

Test plan

  • Configure assetPrefix and crossOrigin in next.config.js
  • Use next/dynamic to lazy-load a component
  • Verify no CORS warnings appear in Chrome DevTools

…chunks

ReactDOM.preload() for next/dynamic scripts was missing crossOrigin,
causing CORS warnings when assetPrefix serves assets from another domain.

Fixes vercel#92904 vercel#92797
@nextjs-bot
Copy link
Copy Markdown
Collaborator

Allow CI Workflow Run

  • approve CI run for commit: 7b3d520

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Copy link
Copy Markdown
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

CSS <link> element in preload-chunks.tsx is missing crossOrigin attribute, causing CORS failures for CSS loaded via next/dynamic when assetPrefix and crossOrigin are configured.

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

next/dynamic preloads missing crossOrigin setting

2 participants