Commit e6448ae4 authored by Ray Schamp's avatar Ray Schamp

Merge pull request #261 from rschamp/feature/better-proxy-fallback

Fall back to scratchr2 in development
parents 10669cab f1fd84e7
...@@ -12,7 +12,6 @@ var webpack = require('webpack'); ...@@ -12,7 +12,6 @@ var webpack = require('webpack');
var handler = require('./handler'); var handler = require('./handler');
var log = require('./log'); var log = require('./log');
var proxies = require('./proxies.json');
var routes = require('./routes.json'); var routes = require('./routes.json');
var isProduction = process.env.NODE_ENV === 'production'; var isProduction = process.env.NODE_ENV === 'production';
...@@ -72,21 +71,6 @@ if (typeof process.env.NODE_SENTRY_DSN === 'string') { ...@@ -72,21 +71,6 @@ if (typeof process.env.NODE_SENTRY_DSN === 'string') {
} }
if (!isProduction) { if (!isProduction) {
// Bind proxies in development
var proxyHost = process.env.PROXY_HOST || 'https://scratch.mit.edu';
app.use('/', proxy(proxyHost, {
filter: function (req) {
for (var i in proxies) {
if (req._path.indexOf(proxies[i]) === 0) return true;
}
return false;
},
forwardPath: function (req) {
return req._path;
}
}));
// Use webpack-dev-server in development // Use webpack-dev-server in development
var compiler = webpack(require('../webpack.config.js')); var compiler = webpack(require('../webpack.config.js'));
app.use(webpackDevMiddleware(compiler, { app.use(webpackDevMiddleware(compiler, {
...@@ -95,6 +79,10 @@ if (!isProduction) { ...@@ -95,6 +79,10 @@ 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));
} }
// Start listening // Start listening
......
[
"/accounts/",
"/csrf_token/",
"/fragment/",
"/get_image/",
"/i18n/setlang/",
"/login_retry/",
"/media/",
"/scratch_admin/homepage/clear-cache/",
"/session/",
"/site-api",
"/static/"
]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment