vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.92k stars 26.87k forks source link

Cdn problem with App Router #65194

Closed veyseltoprak closed 5 months ago

veyseltoprak commented 5 months ago

Link to the code that reproduces this issue

https://github.com/veyseltoprak/approuter-cdn

To Reproduce

I have a project that's coded with nextjs 14 pages router. I have some CDN configuration in that project. (react, react-dom, antd and some others).

When i try to transform my project to 'app router'. I get some errors. (cannot find module) As i sad i have some CDN configuration. If i eliminate react and react-dom from this configuration, it works.

As I understand approuter does not allow react and react dom to be used with CDN.

Is that an issue or not?

Current vs. Expected behavior

Current i can't work with CDN in approuter project. i expect it to work with CDN.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Enterprise
Binaries:
  Node: 20.12.1
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.1.4
  eslint-config-next: 14.1.4
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.4
Next.js Config:
  output: standalone

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

Not sure

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

next dev (local)

Additional context

No response

timneutkens commented 5 months ago

You're likely using the wrong React package. Changing the webpack configuration in this way is not supported, it's overriding the React version Next.js provides.

Keep in mind that setting up a CDN separately from the compiled outputs does not have a positive impact on your application performance as all modern browsers key the JS cache by the requesting domain, so the CDN asset is not shared across multiple domains, this is a common misconception about wanting to use an external hosted CDN.

veyseltoprak commented 5 months ago

Thanks to ingress, we can maintain more than one nextjs application in the same domain. In this way we can utilize from CDN. Do you think that i have a problem with React version? What do you mean? By the way we can already work with CDN on nextjs page router. Could it be related to Approuter?

github-actions[bot] commented 5 months ago

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.