From beb69007cec763df8e419de3818dc4d2b8530ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20R=C3=B6tsch?= Date: Mon, 19 Feb 2018 17:43:09 +0100 Subject: [PATCH] fix(api-selection): fall back to delivery api for invalid apis --- app.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app.js b/app.js index ff2ff83..9094ad2 100644 --- a/app.js +++ b/app.js @@ -84,6 +84,11 @@ app.use(catchErrors(async function (request, response, next) { response.locals.currentApi = apis .find((api) => api.id === (request.query.api || 'cda')) + // Fall back to delivery api if an invalid API is passed + if (!response.locals.currentApi) { + response.locals.currentApi = apis.find((api) => api.id === 'cda') + } + next() }))