From 90495815aeb7e998a16fd9a3ed86fe4ad1befbde Mon Sep 17 00:00:00 2001 From: Anonymous Date: Mon, 5 Aug 2024 15:54:13 +0100 Subject: [PATCH] Bugfix 404 response from getFlowError --- examples/nextjs-spa/src/pages/error.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/nextjs-spa/src/pages/error.tsx b/examples/nextjs-spa/src/pages/error.tsx index 975c7c469..fc0d38660 100644 --- a/examples/nextjs-spa/src/pages/error.tsx +++ b/examples/nextjs-spa/src/pages/error.tsx @@ -51,7 +51,16 @@ const Error: NextPageWithLayout = () => { .then(({ data }) => { setError(JSON.stringify(data, null, 2)) }) - .catch(handleError) + .catch((error: AxiosError) => { + switch (error.response?.status) { + case 404: { + // The kratos handler for /self-service/errors?id=some_error_id currently only handles id=stub:500, and will 404 for everything else + // See https://github.com/ory/kratos/blob/4fb28b363622bb21ce12d9f89d2ceb4649aa0cba/selfservice/errorx/handler.go#L106 + return; + } + } + handleError(error).then(); + }); } }, [err, id, router.isReady, handleError])