import Link from "next/link"; import { Configuration, PublicApi } from "@ory/kratos-client"; import config from "../config"; const kratos = new PublicApi(new Configuration({ basePath: config.kratos.public })); export async function getServerSideProps(context) { const error = context.query.error; // No error was send, redirecting back to home. if (!error || typeof error !== "string") { console.log("No error ID found in URL, redirecting to homepage."); return { redirect: { permanent: false, destination: "/" } }; } try { const { status, data } = await kratos.getSelfServiceError(error); if ("errors" in data) return { props: { errors: data.errors } }; throw new Error(`Expected error ${error} to contain "errors" but got ${JSON.stringify(data)}`); } catch (error) { return { redirect: { permanent: false, destination: "/" } }; } } export default function Error({ errors }) { return (

An error occurred

{errors.map((error, index) => (
1 ? "mt-3 sm:mt-5" : ""} text-center`}>

{error.reason}

))}
back to homepage
); }