diff --git a/__tests__/server/ssrServer.spec.js b/__tests__/server/ssrServer.spec.js index 1fbd85506..452d8b43b 100644 --- a/__tests__/server/ssrServer.spec.js +++ b/__tests__/server/ssrServer.spec.js @@ -676,6 +676,7 @@ describe('ssrServer', () => { '"Fastify application error: method get, url "/example", correlationId "undefined", headersSent: false [Error: testing]"' ); expect(renderStaticErrorPage).toHaveBeenCalledWith(request, reply); + expect(reply.code).toHaveBeenCalledWith(500); }); test('setErrorHandler logs an error and renders the static error page with "headersSent" and "correlationId"', async () => { @@ -709,6 +710,7 @@ describe('ssrServer', () => { '"Fastify application error: method get, url "/example", correlationId "123", headersSent: true [Error: testing]"' ); expect(renderStaticErrorPage).toHaveBeenCalledWith(request, reply); + expect(reply.code).toHaveBeenCalledWith(500); }); }); }); diff --git a/src/server/ssrServer.js b/src/server/ssrServer.js index f695463de..ba85ac77b 100644 --- a/src/server/ssrServer.js +++ b/src/server/ssrServer.js @@ -227,6 +227,7 @@ async function appPlugin(fastify) { request.log.error('Fastify application error: method %s, url "%s", correlationId "%s", headersSent: %s', method, url, correlationId, headersSent, error); + reply.code(500); return renderStaticErrorPage(request, reply); }); }