diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 9bf13c4b..e172db4e 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1,2 @@ - Set Nodejs 14 as minimum version in packages.json (effectively removing Nodev12 from supported versions) +- Add: CORS_ENABLED env var (boolean) to enable the cors configuration (of config.js file) in your docker image (#608) \ No newline at end of file diff --git a/doc/manuals/running.md b/doc/manuals/running.md index dfdaeeab..67ab745d 100644 --- a/doc/manuals/running.md +++ b/doc/manuals/running.md @@ -101,6 +101,7 @@ The environment variables accepted by the script (for which there exists counter - `PROOF_OF_LIFE_INTERVAL`: The time in seconds between proof of life logging messages informing that the server is up and running normally. Default value: "60". `PROCESSED_REQUEST_LOG_STATISTICS_INTERVAL`: The time in seconds between processed requests statistics appear in the logs. Default value: "60". +- `CORS_ENABLED`: Boolean attribute (`true`|`false`) to enable cors configuration. Optional. Default value: "false". For example, to start the STH server listening on port 7777, connecting to a MongoDB instance listening on mymongo.com:27777 and without filtering out the empty results, use: diff --git a/lib/configuration/sthConfiguration.js b/lib/configuration/sthConfiguration.js index 68272df4..224aa556 100644 --- a/lib/configuration/sthConfiguration.js +++ b/lib/configuration/sthConfiguration.js @@ -223,7 +223,10 @@ if (ENV.STH_PORT && !isNaN(ENV.STH_PORT)) { ); } -if (config && config.cors && config.cors.enabled) { +if (ENV.CORS_ENABLED && !(ENV.CORS_ENABLED == null)) { + module.exports.corsEnabled = JSON.parse(ENV.CORS_ENABLED); + sthLogger.info(module.exports.LOGGING_CONTEXT.STARTUP, 'CORS value set to: ' + module.exports.corsEnabled); +} else if (config && config.cors && config.cors.enabled) { module.exports.corsEnabled = JSON.parse(config.cors.enabled); sthLogger.info(module.exports.LOGGING_CONTEXT.STARTUP, 'CORS value set to: ' + module.exports.corsEnabled); } else {