From d630efb23cb96bf2f8e08175f803d5c7597bee28 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Thu, 3 Dec 2015 10:41:02 -0500 Subject: [PATCH] Add `shouldFallback` process env variable So that it's clear to newcomers what things are not yet completed in scratch-www as we build it out. --- README.md | 4 ++++ server/index.js | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d5b86566a..7ad70b36f 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,12 @@ Use `^C` to stop the node process `npm start` starts. | `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) | +| `FALLBACK` | `false` | Whether or not to fallback to `PROXY_HOST` for non-existent pages/reqeusts | | `PROXY_HOST` | `https://scratch.mit.edu` | Pass-through location for scratchr2 | +#### Current issues with the development +* Login does not work (*In the process of being fixed*) + ### To Test ```bash npm test diff --git a/server/index.js b/server/index.js index 58afac386..589873c1f 100644 --- a/server/index.js +++ b/server/index.js @@ -79,10 +79,13 @@ if (!isProduction) { } })); - // Fall back to scratchr2 in development - // This proxy middleware must come last - var proxyHost = process.env.PROXY_HOST || 'https://scratch.mit.edu'; - app.use('/', proxy(proxyHost)); + var shouldFallback = (process.env.FALLBACK === 'true') || false; + if (shouldFallback) { + // Fall back to scratchr2 in development + // This proxy middleware must come last + var proxyHost = process.env.PROXY_HOST || 'https://scratch.mit.edu'; + app.use('/', proxy(proxyHost)); + } } // Start listening