Next.js: CDN url support?

Created on 11 Jan 2017  路  7Comments  路  Source: vercel/next.js

I want to upload all my statics files to CND, including statics files and built JavaScript files(files in .next folder after build).

Is there any way to change the urls to my CDN urls in build phase? For example, the __next/commons.js should be http://mycdnurl.com/__next/v0.1.0/commons.js after build, and also the static files in static folder.

feature request

Most helpful comment

@nkzawa yeah, might have to be a next.config.js setting in that case (which would also make things really easy)

All 7 comments

It could be a property of the NextScripts element when you override <Document>

eg: <NextScripts prefix="" />

I wonder if we should support JSON files of page components too.

@nkzawa yeah, might have to be a next.config.js setting in that case (which would also make things really easy)

Hi @rauchg , assetPrefix doesn't support files located in the static folder. If I want to serve my static files from S3/CDN how would I do it?

Thanks!

@aviramga you can use the with-universal-configuration to set a CDN_PREFIX with the CDN only for production and then use things like <img src={CDN_PREFIX + '/static/my-image.png'} />. Or use path aliases (or similar) to configure domain.com/static to be served through a CDN so you don't need to prefix the files.

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

havefive picture havefive  路  3Comments

DvirSh picture DvirSh  路  3Comments

timneutkens picture timneutkens  路  3Comments

swrdfish picture swrdfish  路  3Comments

wagerfield picture wagerfield  路  3Comments