-
Notifications
You must be signed in to change notification settings - Fork 279
Description
Type: critical
This is a blocker for releases
Describe the bug
The BUILD_GRAPHQL_URL and/or EXTERNAL_GRAPHQL_URL env var is being baked into the JS bundle, likely due to the Next.js / webpack / static build. This bakes unchangeable configuration into the app, which leads to the built docker image on docker hub, being useless if you aren't using the default variables.
Part of the solution for enabling the Next.js static build was maintaining a .env.prod to supply those variables at build time for the production build. This env file is an anti-pattern for the following reasons.
- Promotes a dangerous practice of committing environment vars to a repo in a plain text file.
- Ties configuration to dev/prod when the build should have not care which system it's building for. The built app should run the same if you point it to your dev or production API.
ENV vars should always come from the system, and never be in a file that is committed to source control. The .env and .env.example files are a convenience local development only.
Because of the .env.prod file and the Next.js static build process, we're not able to use our generic Docker image published to Docker hub to run in our test environments, and generic users cannot use it as is without rebuilding.
Expected behavior
- Do not require a static build in
Next.js. This might be related to Optionally allow blocking fallback rendering #716 - Remove
.env.prodand make the build not dependent on that file. It should get its vars from the environment, whether you put them there in a prefix to the command, orcatthem into the env, or set them in CI. - Fix the issue where the GraphQL urls are being baked into the built JS bundle.
- Maybe proxy GraphQL requests through a
Next.jsAPI route so we can take advantage of system environment vars - Somehow make sure config doesn't get bundled
- Maybe proxy GraphQL requests through a