From 8ae0693b1880ec0c6a191b257318a12b6f46ca9a Mon Sep 17 00:00:00 2001 From: Rishabh Poddar Date: Mon, 28 Nov 2022 05:34:43 +0530 Subject: [PATCH] updates with-supertokens example (#43379) Prevents infinite redirect loop if someone is logged in and visits a route like `/auth/random` --- examples/with-supertokens/pages/auth/[[...path]].tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/with-supertokens/pages/auth/[[...path]].tsx b/examples/with-supertokens/pages/auth/[[...path]].tsx index c68106272715..45a62ed3c2bd 100644 --- a/examples/with-supertokens/pages/auth/[[...path]].tsx +++ b/examples/with-supertokens/pages/auth/[[...path]].tsx @@ -3,17 +3,19 @@ import React, { useEffect } from 'react' import styles from '../../styles/Home.module.css' import dynamic from 'next/dynamic' import SuperTokens from 'supertokens-auth-react' -import { redirectToAuth } from 'supertokens-auth-react/recipe/thirdpartyemailpassword' +import { redirectToAuth } from 'supertokens-auth-react' const SuperTokensComponentNoSSR = dynamic( - new Promise((res) => res(SuperTokens.getRoutingComponent)), + new Promise((res) => res(SuperTokens.getRoutingComponent)) as any, { ssr: false } ) export default function Auth(): JSX.Element { useEffect(() => { if (SuperTokens.canHandleRoute() === false) { - redirectToAuth() + redirectToAuth({ + redirectBack: false, + }) } }, [])