Search code examples
reactjsnext.jscdn

Next js | how to dynamically update static folder content over CDN ? i am using assetPrefix in next.config


i am working on a next js application , right now static content is being served from .next/static folder i want to serve static js and css and other file which are there in .next/static folder via a CDN for that in my config next.config.js i have added

module.exports={
    assetPrefix:"https://myTestCDN.com"
}

as per official Next.js Docs

as per the docs user have to upload his .next/static folder content to CDN

my question is how can i update my static content over this cdn every time my application being built

if i built my app locally and transfer content over cdn it would not work because on deployment the build will be different


Solution

  • actually i am able to achieve this, there are two ways to add content to CDN so that it could be delivered on our site one is we manually add content which needs to be delivered on CDN another is we just add our site link as origin url in CDN config , then CDN will itself take the static content from our site and it will be served via CDN