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

CSS not loaded correctly in next@15 when using assetPrefix and next/dynamic #72470

Closed
noreiller opened this issue Nov 7, 2024 · 2 comments · Fixed by #72095
Closed

CSS not loaded correctly in next@15 when using assetPrefix and next/dynamic #72470

noreiller opened this issue Nov 7, 2024 · 2 comments · Fixed by #72095
Labels
bug Issue was opened via the bug report template. Webpack Related to Webpack with Next.js.

Comments

@noreiller
Copy link
Contributor

noreiller commented Nov 7, 2024

Link to the code that reproduces this issue

https://github.com/noreiller/next-15-unfound-asset-with-next-dynamic-and-asset-prefix

To Reproduce

  1. Start the asset proxy web server (to mimic a CDN)
  2. Start the main app using the asset proxy
  3. Go to http://localhost:3000/
  4. See that the texts are not coloured and the CSS are loaded from http://localhost:3000/ instead of http://localhost:4000 while the pathname is ok.

Current vs. Expected behavior

Following the steps from the previous section, I expected the CSS are loaded from the host used in the assetPrefix config and the texts are coloured.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 21:40:26 UTC 2024
  Available memory (MB): 15642
  Available CPU cores: 8
Binaries:
  Node: 18.18.2
  npm: 9.8.1
  Yarn: N/A
  pnpm: 8.2.0
Relevant Packages:
  next: 15.0.3 // Latest available version is detected (15.0.3).
  eslint-config-next: N/A
  react: 19.0.0-rc-66855b96-20241106
  react-dom: 19.0.0-rc-66855b96-20241106
  typescript: 5.3.3
Next.js Config:
  output: N/A

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

Webpack

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

next dev (local), next start (local)

Additional context

I initially proposed a PR (#72095) with the following fix, I'll reopen it. (I closed it since I thought it was fixed.)

The CSS files are loaded on the page only with the pathname instead of using the full URL of the asset.

https://github.com/vercel/next.js/blob/canary/packages/next/src/build/webpack/config/blocks/css/index.ts#L622

- _N_E_STYLE_LOAD(new URL(href).pathname).then(
+ _N_E_STYLE_LOAD(new URL(href).toString()).then(
@noreiller noreiller added the bug Issue was opened via the bug report template. label Nov 7, 2024
@github-actions github-actions bot added the Webpack Related to Webpack with Next.js. label Nov 7, 2024
@ijjk ijjk closed this as completed in cfe66e7 Dec 12, 2024
@yiminghe
Copy link

bug in 15.1.2

@noreiller
Copy link
Contributor Author

bug in 15.1.2

Yes, the fix has not yet been part of a stable release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants