Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using <Script> with crossorigin specified, crossorigin is missing from <link> that preloads the script #65879

Closed
mwskwong opened this issue May 17, 2024 · 1 comment · Fixed by #67423
Labels
bug Issue was opened via the bug report template. locked Script (next/script) Related to Next.js Script Optimization.

Comments

@mwskwong
Copy link

mwskwong commented May 17, 2024

Link to the code that reproduces this issue

https://github.com/mwskwong/missing-cross-origin-from-preload-script

To Reproduce

  1. Build the project
  2. In index.html, observe the <link> that preloads the ad sense script https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js. Note that crossorigin="anonymous" is missing from <link> despite it is specified in <Script>

Current vs. Expected behavior

Current

When including a script with crossOrigin set:

<Script
  async
  crossOrigin="anonymous"
  src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"
/>

crossorigin is missing from the <link> that preloads the script.

Expected

For <link>, crossorigin should be set to the same value as that in <Script>.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home
  Available memory (MB): 32493
  Available CPU cores: 20
Binaries:
  Node: 20.12.2
  npm: N/A
  Yarn: N/A
  pnpm: 8.14.1
Relevant Packages:
  next: 14.3.0-canary.68 // Latest available version is detected (14.3.0-canary.68).
  eslint-config-next: 14.3.0-canary.68
  react: 19.0.0-beta-04b058868c-20240508
  react-dom: 19.0.0-beta-04b058868c-20240508
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Script (next/script)

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), Vercel (Deployed)

Additional context

No response

@mwskwong mwskwong added the bug Issue was opened via the bug report template. label May 17, 2024
@github-actions github-actions bot added the Script (next/script) Related to Next.js Script Optimization. label May 17, 2024
@mwskwong mwskwong changed the title When using <Script>. crossorigin is missing when preloading scripts When using <Script> with crossorigin specified, crossorigin is missing from <link> that preloads the script May 17, 2024
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Script (next/script) Related to Next.js Script Optimization.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant