Next.js Discord

Discord Forum

Customize CDN path

Unanswered
Austrian Black and Tan Hound posted this in #help-forum
Open in Discord
Austrian Black and Tan HoundOP
Next.js provides the capability to set an assetPrefix for integrating with a CDN, which by default includes a predefined path (_next/static/chunks/). This results in asset URLs being formed as https://cdn.mydomain.com/_next/static/chunks/{unique-hash}.{generated-filename}.js. However, if your CDN configuration disallows the use of nested paths such as _next/static/chunks/, leading to a required format of https://cdn.mydomain.com/{hash}/{filename-generated-during-build}.js, you might find the standard setup incompatible.

What adjustments can be made to fully customize the CDN URL structure to accommodate a format that excludes the default path, considering the restrictions imposed by our internal CDN setup?

6 Replies

Keyhole wasp
what CDN are you using?
afaik, _next/static/chunks/... is part of next's core functionality so i don't think you can change that.
this sounds like a configuration issue with your CDN. I can't image what CDN wouldn't allow you to have paths like that.
Austrian Black and Tan HoundOP
Hmm. CDN is internal to the company i work for
Keyhole wasp
I think your options are to get your IT dept to give you what you need or to not use a CDN. like I said, the folder structure of those assets is core to next.js's design.
Austrian Black and Tan HoundOP
Let me try. Thanks for the response. Appreciate that