Merge branch 'pr/2393' into devel

Fixes #1212. Fixes #2393.
This commit is contained in:
David Glasser
2015-01-09 15:54:14 -08:00
3 changed files with 17 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
## v.NEXT
* Fix stack trace when a browser tries to use the server like a proxy. #1212
## v1.0.2.1, 2014-Dec-22

View File

@@ -97,6 +97,10 @@ _.extend(RoutePolicyConstructor.prototype, {
self.urlPrefixTypes[urlPrefix] = type;
},
isValidUrl: function (url) {
return url.charAt(0) === '/';
},
classify: function (url) {
var self = this;
if (url.charAt(0) !== '/')

View File

@@ -565,6 +565,18 @@ var runWebAppServer = function () {
var rawConnectHandlers = connect();
app.use(rawConnectHandlers);
// We're not a proxy; reject (without crashing) attempts to treat us like
// one. (See #1212.)
app.use(function(req, res, next) {
if (RoutePolicy.isValidUrl(req.url)) {
next();
return;
}
res.writeHead(400);
res.write("Not a proxy");
res.end();
});
// Strip off the path prefix, if it exists.
app.use(function (request, response, next) {
var pathPrefix = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX;