next-images: dynamicAssetPrefix does not work as expected
I need to change CDN host after build when server starts.
I try it with statically generated pages (using revalidate option of getStaticProps) and with dynamically generated pages.
All urls change correct except urls to images which I import from js.
I have tried to use dynamicAssetPrefix. My next.config.js looks like this:
const withImages = require('next-images');
module.exports = withImages({
assetPrefix: process.env.CDN,
dynamicAssetPrefix: true,
webpack(config, options) {
return config;
},
});
If I set CDN at build time then this CDN host still does not change when I change CDN env and start server.
And if I leave CDN env empty at build time then I get an error TypeError: Cannot read property 'nextImagesAssetPrefix' of undefined during build.
Is it a bug? or I do something wrong?
What is a correct way to use dynamicAssetPrefix?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (15 by maintainers)
@megazazik Wow nice, I checked your PR I think it makes sense and would solve this issue for sure. Thanks for your contribution, I have never used statically generated pages of Next.js good to have one here who has experience with it 😃