fix: Update config to be flexible for host

This commit is contained in:
Mrugesh Mohapatra
2017-02-22 13:04:21 +00:00
parent d5db2803ad
commit 566de3e3f2
4 changed files with 11 additions and 4 deletions

View File

@ -12,6 +12,7 @@ import { blacklistedUsernames } from '../../server/utils/constants';
const debug = debugFactory('fcc:user:remote'); const debug = debugFactory('fcc:user:remote');
const BROWNIEPOINTS_TIMEOUT = [1, 'hour']; const BROWNIEPOINTS_TIMEOUT = [1, 'hour'];
const isDev = process.env.NODE_ENV !== 'production'; const isDev = process.env.NODE_ENV !== 'production';
const devHost = process.env.HOST || 'localhost';
function getAboutProfile({ function getAboutProfile({
username, username,
@ -443,7 +444,7 @@ module.exports = function(User) {
from: 'Team@freecodecamp.com', from: 'Team@freecodecamp.com',
subject: 'Welcome to freeCodeCamp!', subject: 'Welcome to freeCodeCamp!',
protocol: isDev ? null : 'https', protocol: isDev ? null : 'https',
host: isDev ? 'localhost' : 'freecodecamp.com', host: isDev ? devHost : 'freecodecamp.com',
port: isDev ? null : 443, port: isDev ? null : 443,
template: path.join( template: path.join(
__dirname, __dirname,

View File

@ -1,5 +1,6 @@
// enable debug for gulp // enable debug for gulp
process.env.DEBUG = process.env.DEBUG || 'fcc:*'; process.env.DEBUG = process.env.DEBUG || 'fcc:*';
require('dotenv').load();
require('babel-core/register'); require('babel-core/register');
var Rx = require('rx'), var Rx = require('rx'),
@ -53,6 +54,7 @@ var sync = browserSync.create('fcc-sync-server');
// user definable // user definable
var __DEV__ = !yargs.argv.p; var __DEV__ = !yargs.argv.p;
var host = process.env.HOST || 'localhost';
var port = yargs.argv.port || process.env.PORT || '3001'; var port = yargs.argv.port || process.env.PORT || '3001';
var syncPort = yargs.argv['sync-port'] || process.env.SYNC_PORT || '3000'; var syncPort = yargs.argv['sync-port'] || process.env.SYNC_PORT || '3000';
// make sure sync ui port does not interfere with proxy port // make sure sync ui port does not interfere with proxy port
@ -215,7 +217,7 @@ gulp.task('dev-server', syncDepenedents, function() {
port: syncUIPort port: syncUIPort
}, },
proxy: { proxy: {
target: `http://localhost:${port}`, target: `http://${host}:${port}`,
reqHeaders: ({ url: { hostname } }) => ({ reqHeaders: ({ url: { hostname } }) => ({
host: `${hostname}:${syncPort}` host: `${hostname}:${syncPort}`
}) })

View File

@ -5,6 +5,7 @@ import path from 'path';
const debug = debugFactory('fcc:user:remote'); const debug = debugFactory('fcc:user:remote');
const isDev = process.env.NODE_ENV !== 'production'; const isDev = process.env.NODE_ENV !== 'production';
const devHost = process.env.HOST || 'localhost';
function destroyAllRelated(id, Model) { function destroyAllRelated(id, Model) {
return Observable.fromNodeCallback( return Observable.fromNodeCallback(
@ -77,7 +78,7 @@ module.exports = function(app) {
from: 'Team@freecodecamp.com', from: 'Team@freecodecamp.com',
subject: 'Welcome to freeCodeCamp!', subject: 'Welcome to freeCodeCamp!',
protocol: isDev ? null : 'https', protocol: isDev ? null : 'https',
host: isDev ? 'localhost' : 'freecodecamp.com', host: isDev ? devHost : 'freecodecamp.com',
port: isDev ? null : 443, port: isDev ? null : 443,
template: path.join( template: path.join(
__dirname, __dirname,

View File

@ -4,9 +4,12 @@ let trusted = [
"'self'" "'self'"
]; ];
const host = process.env.HOST || 'localhost';
const port = process.env.PORT || process.env.SYNC_PORT || '3000';
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
trusted = trusted.concat([ trusted = trusted.concat([
'ws://localhost:3000' `ws://${host}:${port}`
]); ]);
} }