Configuration
Automatic environment detection ⚙️
We've implemented a reusable module, which allows us to automatically detect the environment by analyzing NODE_ENV variable. This could be useful on your development machine because you can easily change the environment.
Boostack externalizes static data in the .env file and passes it to your application during execution.
This is normally done by means of environment variables. You just need to define a unique environment variable for each piece of data that needs to be changeable between different environments.
For example: DB_URL
, TOKEN_SECRET
. Then you could pass those values to your app in production this way:
function setProdEnv(app) {
process.env.NODE_ENV = "production";
//DB URL PROD ENV
process.env.DB_URL = process.env.PRODUCTION_DB_DSN;
//PRO ENV SECRET
process.env.TOKEN_SECRET = process.env.TOKEN_SECRET_PROD;
app.use(history());
app.use(
helmet({
contentSecurityPolicy: false,
})
);
}
Last updated
Was this helpful?