Open michael-bouvy opened 4 years ago
Hi there! There is a config option: dynamicConfigReload which is set by default to false. Try just switching it to true - it will cause the config reload by each SSR request which apparently should solve this issue
Thanks @pkarw!
I actually had this option in mind, but didn't think it could help. Will give it a try.
Gave this a try, but I don't get expected result: GraphQL API endpoint used is still production one (as NODE_ENV=production
), despite having set NODE_CONFIG_ENV=my-env
(with config/my-env.json
existing with env-specific conf).
Here is my default.json
conf:
{
"server": {
"dynamicConfigReload": true,
"dynamicConfigContinueOnError": false,
"dynamicConfigExclude": ["entities", "localForage", "shipping", "boost", "query"],
"dynamicConfigInclude": []
},
...
}
I guess this issue should be reopened, @pkarw ? 🙂
Sure, reopening
Please check if this won’t solve the isssue: https://github.com/lorenwest/node-config/wiki/Environment-Variables#custom-environment-variables
We’re using this solution in storefront cloud to pass the variables via env to prebuilt docker containers
This is an interesting feature, but does not fit the need: environment variables are only processed on server side, and from what I can see, once the JS is bundled at build time with a given environment-specific config, values are not reloaded, even with dynamicConfigReload
I’m changing this issue to feature request; the config file is bei ng compiled into app bundle it’s our basic feature from the very beginning; so the suggested solution is to build the app once per ENV because it also involves some code level optimizations, different webpack config, including/excluding source maps. Pretty complex one.
Current behavior
When building in production mode, using
yarn build
the client-side configuration is generated based ondefault.json
,local.json
andproduction.json
(taken fromNODE_ENV
), and written in bothdist/app.*.js
anddist/core-service-worker.js
.This is an issue as a single build may be (re)usable on several environments (ie. staging, preprod, prod), leveraging the
NODE_CONFIG_ENV
environment variable, ie:It actually works fine for server-side calls, as
node-config
loads the config at runtime upon current configured environment.Expected behavior
Configurable values (ie. URLs) should not be hardcoded at build time in generated code (
dist/
directory), so that a single application build can be usable (in a Docker image for instance) on several stages/envs.Steps to reproduce the issue
.graphql.host
tographql-default
inconfig/default.json
.graphql.host
tographql-staging
inconfig/staging.json
.graphql.host
tographql-prod
inconfig/production.json
yarn build
(which will run in production mode, asNODE_ENV=production
inpackage.json
config forbuild
command)NODE_CONFIG_ENV=staging yarn start
:arrow_down:
graphql-staging
hostname :white_check_mark:graphql-prod
hostname, taken fromdist/*.js
files :x:Can you handle fixing this bug by yourself?
Which Release Cycle state this refers to? Info for developer.
Pick one option.
develop
branch and create Pull Request2. Feature / Improvement
back todevelop
.release
branch and create Pull Request3. Stabilisation fix
back torelease
.hotfix
ormaster
branch and create Pull Request4. Hotfix
back tohotfix
.Environment details