mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-17 00:21:20 -05:00
Merge pull request #261 from rschamp/feature/better-proxy-fallback
Fall back to scratchr2 in development
This commit is contained in:
commit
e6448ae4bf
2 changed files with 4 additions and 29 deletions
|
@ -12,7 +12,6 @@ var webpack = require('webpack');
|
|||
|
||||
var handler = require('./handler');
|
||||
var log = require('./log');
|
||||
var proxies = require('./proxies.json');
|
||||
var routes = require('./routes.json');
|
||||
|
||||
var isProduction = process.env.NODE_ENV === 'production';
|
||||
|
@ -72,21 +71,6 @@ if (typeof process.env.NODE_SENTRY_DSN === 'string') {
|
|||
}
|
||||
|
||||
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
|
||||
var compiler = webpack(require('../webpack.config.js'));
|
||||
app.use(webpackDevMiddleware(compiler, {
|
||||
|
@ -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
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
[
|
||||
"/accounts/",
|
||||
"/csrf_token/",
|
||||
"/fragment/",
|
||||
"/get_image/",
|
||||
"/i18n/setlang/",
|
||||
"/login_retry/",
|
||||
"/media/",
|
||||
"/scratch_admin/homepage/clear-cache/",
|
||||
"/session/",
|
||||
"/site-api",
|
||||
"/static/"
|
||||
]
|
Loading…
Reference in a new issue