Use config when starting development server (#9410)

* Use config when starting development server

* import nconf setup from website

* Add comment explaining choice

* Fix lint issues
This commit is contained in:
MathWhiz
2017-11-27 20:38:27 -06:00
committed by Sabe Jones
parent dd05a8d608
commit 200cd66d66
3 changed files with 19 additions and 16 deletions

View File

@@ -3,6 +3,14 @@ const path = require('path');
const staticAssetsDirectory = './website/static/.'; // The folder where static files (not processed) live
const prodEnv = require('./prod.env');
const devEnv = require('./dev.env');
const nconf = require('nconf');
const setupNconf = require('../../website/server/libs/setupNconf');
let configFile = path.join(path.resolve(__dirname, '../../config.json'));
setupNconf(configFile);
const DEV_BASE_URL = nconf.get('BASE_URL');
module.exports = {
build: {
@@ -33,25 +41,25 @@ module.exports = {
assetsPublicPath: '/',
staticAssetsDirectory,
proxyTable: {
// proxy all requests starting with /api/v3 to localhost:3000
// proxy all requests starting with /api/v3 to IP:PORT as specified in the top-level config
'/api/v3': {
target: 'http://localhost:3000',
target: DEV_BASE_URL,
changeOrigin: true,
},
'/stripe': {
target: 'http://localhost:3000',
target: DEV_BASE_URL,
changeOrigin: true,
},
'/amazon': {
target: 'http://localhost:3000',
target: DEV_BASE_URL,
changeOrigin: true,
},
'/paypal': {
target: 'http://localhost:3000',
target: DEV_BASE_URL,
changeOrigin: true,
},
'/logout': {
target: 'http://localhost:3000',
target: DEV_BASE_URL,
changeOrigin: true,
},
},

View File

@@ -1,17 +1,11 @@
const nconf = require('nconf');
const { join, resolve } = require('path');
const setupNconf = require('../../website/server/libs/setupNconf');
const PATH_TO_CONFIG = join(resolve(__dirname, '../../config.json'));
let configFile = PATH_TO_CONFIG;
nconf
.argv()
.env()
.file('user', configFile);
nconf.set('IS_PROD', nconf.get('NODE_ENV') === 'production');
nconf.set('IS_DEV', nconf.get('NODE_ENV') === 'development');
nconf.set('IS_TEST', nconf.get('NODE_ENV') === 'test');
setupNconf(configFile);
// @TODO: Check if we can import from client. Items like admin emails can be imported
// and that should be prefered

View File

@@ -1,5 +1,6 @@
import nconf from 'nconf';
import { join, resolve } from 'path';
// require allows import from webpack
const nconf = require('nconf');
const { join, resolve } = require('path');
const PATH_TO_CONFIG = join(resolve(__dirname, '../../../config.json'));