From 38322e1412e37112faa46fd3eec8ece464462bd2 Mon Sep 17 00:00:00 2001 From: chris48s <chris48s@users.noreply.github.com> Date: Sun, 6 Sep 2020 18:21:58 +0100 Subject: [PATCH] redirect /endpoint with no query params to endpoint docs (#5137) Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com> --- core/base-service/legacy-request-handler.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/base-service/legacy-request-handler.js b/core/base-service/legacy-request-handler.js index 3d3096a5ec..60090d9d9e 100644 --- a/core/base-service/legacy-request-handler.js +++ b/core/base-service/legacy-request-handler.js @@ -107,6 +107,20 @@ function handleRequest(cacheHeaderConfig, handlerOptions) { } = handlerOptions return (queryParams, match, end, ask) => { + /* + This is here for legacy reasons. The badge server and frontend used to live + on two different servers. When we merged them there was a conflict so we + did this to avoid moving the endpoint docs to another URL. + + Never ever do this again. + */ + if (match[0] === '/endpoint' && Object.keys(queryParams).length === 0) { + ask.res.statusCode = 301 + ask.res.setHeader('Location', '/endpoint/') + ask.res.end() + return + } + const reqTime = new Date() // `defaultCacheLengthSeconds` can be overridden by -- GitLab