https://supertokens.com/ logo
#support-questions
Title
# support-questions
f

finthechat007

04/20/2022, 3:53 AM
I followed the steps in this docs https://supertokens.com/docs/emailpassword/nextjs/init but I'm getting an infinite redirect
r

rp

04/20/2022, 3:54 AM
What’s your frontend config like?
f

finthechat007

04/20/2022, 3:54 AM
Copy code
export const appInfo = {
  // learn more about this on https://supertokens.com/docs/emailpassword/appinfo
  appName: "z8",
  apiDomain: "http://localhost:5000",
  websiteDomain: "http://localhost:3000",
  apiBasePath: "/auth",
  websiteBasePath: "/auth",
};
Copy code
import EmailPasswordReact from "supertokens-auth-react/recipe/emailpassword";
import SessionReact from "supertokens-auth-react/recipe/session";
import { appInfo } from "./appInfo";

export const frontendConfig = () => {
  return {
    appInfo,
    recipeList: [EmailPasswordReact.init(), SessionReact.init()],
  };
};
then in _app.tsx I have this
Copy code
import "../styles/globals.css";
import { QueryClient, QueryClientProvider } from "react-query";
import type { AppProps } from "next/app";
import SuperTokensReact from "supertokens-auth-react";
import EmailPassword from "supertokens-auth-react/recipe/emailpassword";

import { frontendConfig } from "../config/frontendConfig";
import dynamic from "next/dynamic";

if (typeof window !== "undefined") {
  // we only want to call this init function on the frontend, so we check typeof window !== 'undefined'
  SuperTokensReact.init(frontendConfig());
}

const EmailPasswordAuthNoSSR = dynamic(
  new Promise((res) => res(EmailPassword.EmailPasswordAuth)) as any,
  { ssr: false }
);

const queryClient = new QueryClient();

function MyApp({ Component, pageProps }: AppProps) {
  
  return (
    <EmailPasswordAuthNoSSR>
      <QueryClientProvider client={queryClient}>
        <Component {...pageProps} />
      </QueryClientProvider>
    </EmailPasswordAuthNoSSR>
  );
}

export default MyApp;
it was working a couple of weeks ago, I deleted the cookies and then saw this behavior
r

rp

04/20/2022, 3:57 AM
Can you enable debug logging and then show me the output?
f

finthechat007

04/20/2022, 3:57 AM
how can I enable it?
r

rp

04/20/2022, 3:58 AM
There is a troubleshooting section in the docs
r

rp

04/20/2022, 3:58 AM
And is EmailPasswordAuthNoSSR being used for all routes? Even the /auth route?
f

finthechat007

04/20/2022, 3:59 AM
yep, do you think that might be the issue?
r

rp

04/20/2022, 3:59 AM
Cause that would cause an infinite redirect
Yeaa
f

finthechat007

04/20/2022, 3:59 AM
let me try adding it to individual routes
r

rp

04/20/2022, 3:59 AM
Yup
f

finthechat007

04/20/2022, 4:01 AM
it works πŸ˜„
thank you very much!
it's weird because I swear it was working a couple of weeks ago
I really appreciate your help πŸ™‚
r

rp

04/20/2022, 4:02 AM
Hmm
πŸ‘
2 Views