From 0bfd6e14300bab5382c2d9191076c49a9bf12beb Mon Sep 17 00:00:00 2001 From: Andrew Sliwinski Date: Tue, 3 Nov 2015 10:44:56 -0500 Subject: [PATCH 1/2] Update environment defaults --- README.md | 4 ++-- server/config.js | 3 +++ server/index.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b3cddd7b0..e1d348f2a 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,10 @@ npm stop | Variable | Default | Description | | ------------- | ------------------------------------- | ---------------------------------------------- | -| `API_HOST` | `https://api-staging.scratch.mit.edu` | Hostname for API requests | +| `API_HOST` | `https://api.scratch.mit.edu` | Hostname for API requests | | `NODE_ENV` | `null` | If not `production`, app acts like development | | `PORT` | `8333` | Port for devserver (http://localhost:XXXX) | -| `PROXY_HOST` | `https://staging.scratch.mit.edu` | Pass-through location for scratchr2 | +| `PROXY_HOST` | `https://scratch.mit.edu` | Pass-through location for scratchr2 | ### To Test ```bash diff --git a/server/config.js b/server/config.js index 3d6f91255..51c441a65 100644 --- a/server/config.js +++ b/server/config.js @@ -1,4 +1,7 @@ module.exports = { + // Bind environment + api_host: process.env.API_HOST || 'https://api.scratch.mit.edu', + // Search and metadata title: 'Imagine, Program, Share', description: diff --git a/server/index.js b/server/index.js index e206d2955..4dad22595 100644 --- a/server/index.js +++ b/server/index.js @@ -67,7 +67,7 @@ if (typeof process.env.SENTRY_DSN === 'string') { // Bind proxies in development if (process.env.NODE_ENV !== 'production') { - var proxyHost = process.env.PROXY_HOST || 'https://staging.scratch.mit.edu'; + var proxyHost = process.env.PROXY_HOST || 'https://scratch.mit.edu'; app.use('/', proxy(proxyHost, { filter: function (req) { From 06de644ae6802ebe90c30186d977e65c10d85f60 Mon Sep 17 00:00:00 2001 From: Andrew Sliwinski Date: Tue, 3 Nov 2015 10:49:32 -0500 Subject: [PATCH 2/2] Remove ./src/environment from Webpack config and bind environment to window. Resolves GH-199. --- server/template.html | 11 ++++++++--- src/environment.js | 6 ------ src/lib/render.jsx | 8 +++----- src/mixins/api.jsx | 2 +- webpack.config.js | 4 ---- 5 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 src/environment.js diff --git a/server/template.html b/server/template.html index 6102ec4bf..0caa161cd 100644 --- a/server/template.html +++ b/server/template.html @@ -28,10 +28,15 @@ - - + + - + + diff --git a/src/environment.js b/src/environment.js deleted file mode 100644 index dc05b740b..000000000 --- a/src/environment.js +++ /dev/null @@ -1,6 +0,0 @@ -var Environment = { - NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development'), - API_HOST: JSON.stringify(process.env.API_HOST || 'https://api-staging.scratch.mit.edu') -}; - -module.exports = Environment; diff --git a/src/lib/render.jsx b/src/lib/render.jsx index 3e6b36750..8d4e642f6 100644 --- a/src/lib/render.jsx +++ b/src/lib/render.jsx @@ -15,11 +15,9 @@ var render = function (jsx, element) { element ); - // If in production, provide list of rendered components - if (process.env.NODE_ENV != 'production') { - window._renderedComponents = window._renderedComponents || []; - window._renderedComponents.push(component); - } + // Provide list of rendered components + window._renderedComponents = window._renderedComponents || []; + window._renderedComponents.push(component); }; module.exports = render; diff --git a/src/mixins/api.jsx b/src/mixins/api.jsx index be344bd32..6ffeca5a4 100644 --- a/src/mixins/api.jsx +++ b/src/mixins/api.jsx @@ -13,7 +13,7 @@ var Api = { ], api: function (opts, callback) { defaults(opts, { - host: process.env.API_HOST, + host: window.env.API_HOST, headers: {}, json: {}, useCsrf: false diff --git a/webpack.config.js b/webpack.config.js index ba6f26988..41a186e6f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,7 +1,6 @@ var path = require('path'); var webpack = require('webpack'); -var environment = require('./src/environment.js'); var routes = require('./server/routes.json'); // Prepare all entry points @@ -53,9 +52,6 @@ module.exports = { fs: 'empty' }, plugins: [ - new webpack.DefinePlugin({ - 'process.env': environment - }), new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false