diff --git a/common/models/user.js b/common/models/user.js index ef58e58918..7ada5854fd 100644 --- a/common/models/user.js +++ b/common/models/user.js @@ -12,6 +12,7 @@ import { blacklistedUsernames } from '../../server/utils/constants'; const debug = debugFactory('fcc:user:remote'); const BROWNIEPOINTS_TIMEOUT = [1, 'hour']; const isDev = process.env.NODE_ENV !== 'production'; +const devHost = process.env.HOST || 'localhost'; function getAboutProfile({ username, @@ -443,7 +444,7 @@ module.exports = function(User) { from: 'Team@freecodecamp.com', subject: 'Welcome to freeCodeCamp!', protocol: isDev ? null : 'https', - host: isDev ? 'localhost' : 'freecodecamp.com', + host: isDev ? devHost : 'freecodecamp.com', port: isDev ? null : 443, template: path.join( __dirname, diff --git a/gulpfile.js b/gulpfile.js index b080e887e2..0ba252325f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,6 @@ // enable debug for gulp process.env.DEBUG = process.env.DEBUG || 'fcc:*'; +require('dotenv').load(); require('babel-core/register'); var Rx = require('rx'), @@ -53,6 +54,7 @@ var sync = browserSync.create('fcc-sync-server'); // user definable var __DEV__ = !yargs.argv.p; +var host = process.env.HOST || 'localhost'; var port = yargs.argv.port || process.env.PORT || '3001'; var syncPort = yargs.argv['sync-port'] || process.env.SYNC_PORT || '3000'; // make sure sync ui port does not interfere with proxy port @@ -215,7 +217,7 @@ gulp.task('dev-server', syncDepenedents, function() { port: syncUIPort }, proxy: { - target: `http://localhost:${port}`, + target: `http://${host}:${port}`, reqHeaders: ({ url: { hostname } }) => ({ host: `${hostname}:${syncPort}` }) diff --git a/server/boot/a-extendUser.js b/server/boot/a-extendUser.js index 0d5dddaa44..507384b473 100644 --- a/server/boot/a-extendUser.js +++ b/server/boot/a-extendUser.js @@ -5,6 +5,7 @@ import path from 'path'; const debug = debugFactory('fcc:user:remote'); const isDev = process.env.NODE_ENV !== 'production'; +const devHost = process.env.HOST || 'localhost'; function destroyAllRelated(id, Model) { return Observable.fromNodeCallback( @@ -77,7 +78,7 @@ module.exports = function(app) { from: 'Team@freecodecamp.com', subject: 'Welcome to freeCodeCamp!', protocol: isDev ? null : 'https', - host: isDev ? 'localhost' : 'freecodecamp.com', + host: isDev ? devHost : 'freecodecamp.com', port: isDev ? null : 443, template: path.join( __dirname, diff --git a/server/middlewares/csp.js b/server/middlewares/csp.js index 50548cd878..3fae20e8ec 100644 --- a/server/middlewares/csp.js +++ b/server/middlewares/csp.js @@ -4,9 +4,12 @@ let trusted = [ "'self'" ]; +const host = process.env.HOST || 'localhost'; +const port = process.env.PORT || process.env.SYNC_PORT || '3000'; + if (process.env.NODE_ENV !== 'production') { trusted = trusted.concat([ - 'ws://localhost:3000' + `ws://${host}:${port}` ]); }