Describe the bug
If you attempt to use environment variables to override an empty setting, it won't work.
Take the setting rest.ssrBaseUrl as an example:
If you attempt to specify it via an environment variable, that value will be ignored
DSPACE_REST_SSRBASEURL: http://localhost:8080/server
This issue impacts all settings which are not listed in default-app-config.ts.
One way to fix this issue would be to ensure all settings with empty default values are added to default-app-config.ts. They could be given an empty string value in that file, or some other sane default. However, we'd need to ensure there are no side effects (in other areas of the code) to giving these settings a default value. (I also feel this is a semi-fragile fix, as we'd have to remember to always add every setting to default-app-config.ts)
To Reproduce
Steps to reproduce the behavior:
- Set the environment variable
DSPACE_REST_SSRBASEURL to http://localhost:8080/server as shown above
- Start up the UI in production mode:
npm run build:prod; npm run serve:ssr
- Notice that the SSR logs will NOT say:
Applying environment variable DSPACE_UI_SSRBASEURL with value http://localhost:8080/server
- Stop the UI
- Now, modify the
default-app-config.ts to add a default value for ssrBaseUrl:
rest: ServerConfig = {
...
// Just add this line - The value you give it doesn't matter
ssrBaseUrl: 'http://dspace.org',
};
- Rebuild the UI and run again in production mode:
npm run build:prod; npm run serve:ssr
- Notice that the SSR Logs will now say:
Applying environment variable DSPACE_UI_SSRBASEURL with value http://localhost:8080/server
Expected behavior
It should be possible to use environment variables to give a value to empty settings.
Related work
Discovered while debugging issues with #5276 . This PR was attempting to use an empty setting ui.BaseUrl which could NOT be overridden in Docker Compose scripts until that setting was added to default-app-config.ts with a default value.
Describe the bug
If you attempt to use environment variables to override an empty setting, it won't work.
Take the setting
rest.ssrBaseUrlas an example:default-app-config.tsconfig.ymlserver-config.interface.tsrest.ssrBaseUrldefaults to an empty value.If you attempt to specify it via an environment variable, that value will be ignored
This issue impacts all settings which are not listed in
default-app-config.ts.One way to fix this issue would be to ensure all settings with empty default values are added to
default-app-config.ts. They could be given an empty string value in that file, or some other sane default. However, we'd need to ensure there are no side effects (in other areas of the code) to giving these settings a default value. (I also feel this is a semi-fragile fix, as we'd have to remember to always add every setting todefault-app-config.ts)To Reproduce
Steps to reproduce the behavior:
DSPACE_REST_SSRBASEURLtohttp://localhost:8080/serveras shown abovenpm run build:prod; npm run serve:ssrApplying environment variable DSPACE_UI_SSRBASEURL with value http://localhost:8080/serverdefault-app-config.tsto add a default value forssrBaseUrl:npm run build:prod; npm run serve:ssrApplying environment variable DSPACE_UI_SSRBASEURL with value http://localhost:8080/serverExpected behavior
It should be possible to use environment variables to give a value to empty settings.
Related work
Discovered while debugging issues with #5276 . This PR was attempting to use an empty setting
ui.BaseUrlwhich could NOT be overridden in Docker Compose scripts until that setting was added todefault-app-config.tswith a default value.