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

app dir next.config.js option crossOrigin: 'anonymous' not working #53190

Closed
1 task done
limi58 opened this issue Jul 26, 2023 · 2 comments · Fixed by #56311
Closed
1 task done

app dir next.config.js option crossOrigin: 'anonymous' not working #53190

limi58 opened this issue Jul 26, 2023 · 2 comments · Fixed by #56311
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked

Comments

@limi58
Copy link

limi58 commented Jul 26, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023
    Binaries:
      Node: 18.16.0
      npm: 9.5.1
      Yarn: N/A
      pnpm: 8.6.2
    Relevant Packages:
      next: 13.4.12
      eslint-config-next: 13.4.12
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.3
    Next.js Config:
      output: standalone

Which area(s) of Next.js are affected? (leave empty if unsure)

App Router

Link to the code that reproduces this issue or a replay of the bug

https://codesandbox.io/p/sandbox/boring-dust-mjv4ps

To Reproduce

  1. open above codesandbox link
  2. see next.config.js exises crossOrigin: 'anonymous' option
  3. open browser console, see script is not exises crossOrigin: 'anonymous'

Describe the Bug

nextjs v13, app dir, next.config.js exises crossOrigin: 'anonymous' option but not working

Expected Behavior

how to add crossOrigin='anonymous' to script ?

Which browser are you using? (if relevant)

Chrome 114.0.0.0

How are you deploying your application? (if relevant)

next start

NEXT-1475

@limi58 limi58 added the bug Issue was opened via the bug report template. label Jul 26, 2023
@balazsorban44 balazsorban44 added the linear: next Confirmed issue that is tracked by the Next.js team. label Jul 27, 2023
@SukkaW
Copy link
Contributor

SukkaW commented Sep 26, 2023

Next.js stores the value of config.crossOrigin inside process.env.__NEXT_CROSS_ORIGIN, and is inlined during the build. The App Router rendering (app-render.ts) just does not respect the process.env.__NEXT_CROSS_ORIGIN, hence the issue.

I will work on this issue then.

SukkaW added a commit to SukkaW/next.js that referenced this issue Oct 2, 2023
SukkaW added a commit to SukkaW/next.js that referenced this issue Oct 2, 2023
@kodiakhq kodiakhq bot closed this as completed in #56311 Oct 2, 2023
kodiakhq bot pushed a commit that referenced this issue Oct 2, 2023
Fixes #53190.

Next.js App Router comprises two categories of resources, same-origin ones (RSC payload, in the form of inline `<script />`) and possibly third-party ones (chunks that respect the `assetPrefix`). The latter should also respect the `crossOrigin` option from `next.config.js`.

Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
@github-actions
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 Oct 17, 2023
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. linear: next Confirmed issue that is tracked by the Next.js team. locked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants