Replies: 1 comment
-
Great question! This build vs runtime environment challenge is definitely a pain point. I think your instinct about a runtime script replacement might be the most flexible approach. It would keep the build artifact environment-agnostic while allowing configuration changes during deployment. Looking forward to seeing what solutions the community suggests! This would benefit a lot of Next.js projects. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
Background
The problem is that while runtime env variables are a great way make nextjs project environment agnostic, the build step in nextjs means that certain features used in next.config.js will not work in different environments. For example, the assetPrefix property, once built in one environment, cannot be changed.
Proposal
I don't know what the best way to deal with this is. Maybe it's a two part build process. Maybe it's a small script to replace variables at runtime. Maybe there's a way to set assetPrefix using runtime environment variables.
Beta Was this translation helpful? Give feedback.
All reactions