diff --git a/api/src/plugins/not-found.ts b/api/src/plugins/not-found.ts index 4ed4b187d65..ca66e4a1305 100644 --- a/api/src/plugins/not-found.ts +++ b/api/src/plugins/not-found.ts @@ -14,17 +14,20 @@ import { getRedirectParams } from '../utils/redirection'; const fourOhFour: FastifyPluginCallback = (fastify, _options, done) => { // If the request accepts JSON and does not specifically prefer text/html, // this will return a 404 JSON response. Everything else will be redirected. - fastify.setNotFoundHandler((request, reply) => { - const accepted = request.accepts().type(['json', 'html']); + fastify.setNotFoundHandler((req, reply) => { + const logger = fastify.log.child({ req }); + const accepted = req.accepts().type(['json', 'html']); + + logger.debug('User requested path that does not exist'); if (accepted == 'json') { void reply.code(404).send({ error: 'path not found' }); } else { - const { origin } = getRedirectParams(request); + const { origin } = getRedirectParams(req); void reply.status(302); void reply.redirectWithMessage(`${origin}/404`, { type: 'danger', - content: `We couldn't find path ${request.url}` + content: `We couldn't find path ${req.url}` }); } });