From c154325f3eb0e49e276b3601559a82df9c4b4078 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Fri, 3 Jun 2016 14:52:52 -0400 Subject: [PATCH] Redirect to /v1 if no legacy proxy specified For when we have multiple active API versions, we have code to redirect from one running API server to another. Right now, we've disabled the beta/legacy API server and haven't released a V2 yet, so we currently have no proxying configured. Right now the default with no configuration is to simply return an error. However that means that request to http://search.mapzen.com/ return that unfriendly error. We have a nice friendly /v1 page, so in the case of no proxy being set up, it makes sense to redirect to that. --- routes/legacy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/legacy.js b/routes/legacy.js index fc6857b9..1de4986d 100644 --- a/routes/legacy.js +++ b/routes/legacy.js @@ -4,8 +4,8 @@ function addRoutes(app, peliasConfig) { var sendToLegacy; if (!peliasConfig.hasOwnProperty('legacyUrl')) { - sendToLegacy = function doNothing(req, res, next) { - next(new Error('Invalid path, no legacy proxy specified')); + sendToLegacy = function redirectToV1(req, res, next) { + res.redirect(301, '/v1'); }; } else {