Browse Source

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.
pull/555/head
Julian Simioni 9 years ago
parent
commit
c154325f3e
No known key found for this signature in database
GPG Key ID: 6DAD08919FDBF563
  1. 4
      routes/legacy.js

4
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 {

Loading…
Cancel
Save