fix(api-selection): fall back to delivery api for invalid apis

This commit is contained in:
Benedikt Rötsch
2018-02-19 17:43:09 +01:00
committed by Benedikt Rötsch
parent 5e55d7b5b4
commit beb69007ce

5
app.js
View File

@@ -84,6 +84,11 @@ app.use(catchErrors(async function (request, response, next) {
response.locals.currentApi = apis response.locals.currentApi = apis
.find((api) => api.id === (request.query.api || 'cda')) .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() next()
})) }))