# 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&#x20;

* [dotenv install in your project](https://www.npmjs.com/package/dotenv)
* [a dotenv file](https://softstack-factory.gitbook.io/mean-stack/deployment/learn-environment-variables#using-dotenv)
* [Learn Environment Variables](https://softstack-factory.gitbook.io/mean-stack/deployment/deploying-loopback/learn-environment-variables)
* [Using Environment Variables in Loopback](https://softstack-factory.gitbook.io/mean-stack/deployment/deploying-loopback/loopback-environment-variables)

## Production Configuration

For more details on how loopback uses different configurations you can see [Loopback 3 Docs](https://loopback.io/doc/en/lb3/Environment-specific-configuration.html)&#x20;

{% tabs %}
{% tab title="Step One" %}
Your `datasources.local.js` should look something like below:

{% embed url="<https://gist.github.com/ssffacilitator/ffe064112d306674b80d74713d52149e>" %}

In the server folder create a new file name `datasources.production.js`  and then copy and paste in your code from `datasources.local.js`
{% endtab %}

{% tab title="Step Two" %}
Now in your terminal restart the loopback app with the following command

```
NODE_ENV=production node .
```

Your app should build.

![](https://3729111192-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LJF8uz6T7DhCLClK6jV%2F-LyQTY6wj4fIfe5_H0Vq%2F-LyQVrg9A4muTzRMe9SN%2Fimage.png?alt=media\&token=b12e5058-9bcf-4874-9c98-a837d1ece69c)

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.&#x20;

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](https://loopback.io/doc/en/lb3/Environment-specific-configuration.html#disabling-api-explorer).

{% endtab %}
{% endtabs %}

{% hint style="success" %}
**SUCCESS** your application can use different configurations based on the **NODE\_ENV** variable
{% endhint %}
