Reputation: 1589
I found documentation for the previous version https://loopback.io/doc/en/lb3/Environment-specific-configuration.html but I can't find a documentation for the version 4
There's something I'm missing or v4 doesn't yet support environment specific configuration?
Upvotes: 11
Views: 6766
Reputation: 868
After breaking my head looking for documentation - these are the steps I used to handle environment configuration:
Step 1: Install dotenv package
npm install --s dotenv
Add a .env
file to the root of your project (server/.env). Sample format in this file given below:
SampleKey=testValue
Require this file from the index.js file (I placed this on line 2)
// Addition of dotenv for access to process.env (environment variables)
const dotenv = require('dotenv').config();
You should be able to access keys from your file now as follows:
console.log(process.env.SampleKey);
Upvotes: 14
Reputation: 1027
Loopback 4 doesn't support environment specific configurations yet. Check this post https://stackoverflow.com/a/53377667/3904327
You can follow this github issue for the same. https://github.com/strongloop/loopback-next/issues/1464
Upvotes: 4