Production Environment
Overview
We almost always will have different a different configuration for our production deployment of an app than we will for our local development. In this section we setup our application to have different configurations based one the NODE_ENV environment variable.
Prerequisites
Production Configuration
For more details on how loopback uses different configurations you can see Loopback 3 Docs
Your datasources.local.js should look something like below:
In the server folder create a new file name datasources.production.js and then copy and paste in your code from datasources.local.js
Now in your terminal restart the loopback app with the following command
NODE_ENV=production node .Your app should build.

When we set the NODE_ENV=production when loopback starts it looks for files in the server folder that have datasources.production.js or lets say component-config.production.json production in the filename and uses those override the default configuration.
One thing a production environment might do is disable the looopback explorer so that you don't expose your database to threats and attacks, click this link for the documentation.
SUCCESS your application can use different configurations based on the NODE_ENV variable
Last updated