我正在尝试创建一个工具来查看我们的项目配置JSON文件。配置是根据设置的process.env变量生成的。我创建了一个Express服务器,其中一个路由侦听环境变量并返回相应的JSON配置。但是这仅适用于第一个请求,正在更改正确的process.env变量,但返回的JSON配置仅反映第一个请求。以下是POST路由 - 应更改fpconf对象以反映正在发送的请求参数。我有什么遗失的东西吗?
app.post( '/json', function ( req, res, next ) {
res.header( "Access-Control-Allow-Origin", "*" );
res.header( "Access-Control-Allow-Headers", "Origin, X-Requested- With, Content-Type, Accept" );
console.log( req.body );
_.merge( process.env, req.body );// Sets environment variables grabbed from post request
console.log( process.env ); // Log to ensure environment variables have been changed.
var fpUtils = appRootPath.require( '/libs/helpers/fputils' ),
fpconf = appRootPath.require( '/libs/fp-conf' );///file that returns the configuration JSON
console.log( "instance is " + process.env.NODE_APP_INSTANCE + ", deployment is " + process.env.NODE_ENV )
console.log(fpconf.data);
res.send( fpconf.data );
});