Problem requirement: The interface IP will change during project testing. I want to reduce the need to manually modify the IP address of the interface each time by setting NODE_NEV.
Problem description:
Configuration method of NODE_NEV in express
The following is the code found, but it does not take effect after startup.
common.js
var envJson = {
"development": {
"facebook_app_id": "facebook_dummy_dev_app_id",
"facebook_app_secret": "facebook_dummy_dev_app_secret",
},
"production": {
"facebook_app_id": "facebook_dummy_prod_app_id",
"facebook_app_secret": "facebook_dummy_prod_app_secret",
}
}
exports.envJson = function() {
var node_env = process.env.NODE_ENV || env.development;
return envJson[node_env];
};
app.js
var envJson = common.envJson();
var facebook_app_id = envJson.facebook_app_id;
Edit
package.json
’sscripts
Start the production environment
Start the development environment