Runtime Config in next.config.js
Unanswered
Birman posted this in #help-forum
BirmanOP
I'm trying to put cdn domain as assetPrefix and it always resolves on build time however I want to resolve during runtime. Is there a possible way to do it? I want to do this to share same docker image across enviorments. Following is how my config file looks like -
const cloudFrontUrl = process.env.CDN_DOMAIN
const nextConfig = {
transpilePackages: packages,
assetPrefix: cloudFrontUrl,
output: 'standalone',
webpack: (config) =>2 Replies
BirmanOP
Bumping up.
Cuban Crocodile
We created the image by having .env file as
NEXT_CDN_URL=NEXT_ENV_START_NEXT_CDN_URL_NEXT_ENV_END
And when container starts we run a script to replace NEXT_ENV_START_NEXT_CDN_URL_NEXT_ENV_END with process.env.cdn_domain from k8..
Its not a proper solution but works
NEXT_CDN_URL=NEXT_ENV_START_NEXT_CDN_URL_NEXT_ENV_END
And when container starts we run a script to replace NEXT_ENV_START_NEXT_CDN_URL_NEXT_ENV_END with process.env.cdn_domain from k8..
Its not a proper solution but works