From 25fd235e102affdc1800f383d190e4224ef9af46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20T=C3=B3rz?= Date: Mon, 24 Jul 2023 12:51:16 +0200 Subject: [PATCH] Fix error page status code --- .../src/api/middleware/frontendErrorMiddleware.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/api/middleware/frontendErrorMiddleware.ts b/packages/backend/src/api/middleware/frontendErrorMiddleware.ts index 2db1fea48..4e6fed14c 100644 --- a/packages/backend/src/api/middleware/frontendErrorMiddleware.ts +++ b/packages/backend/src/api/middleware/frontendErrorMiddleware.ts @@ -14,22 +14,25 @@ export async function frontendErrorMiddleware( const givenUser = getGivenUser(ctx) const context = await pageContextService.getPageContext(givenUser) - switch (ctx.status) { + const statusCode = ctx.status + switch (statusCode) { case 400: case 404: ctx.set({ 'Content-Type': 'text/html' }) ctx.body = renderErrorPage({ context, - statusCode: ctx.status, + statusCode, message: ctx.customMessage as string, }) + ctx.status = statusCode break case 500: ctx.set({ 'Content-Type': 'text/html' }) ctx.body = renderErrorPage({ context, - statusCode: ctx.status, + statusCode, }) + ctx.status = statusCode break } }