a_tree.
02/09/2024, 8:46 PMa_tree.
02/09/2024, 8:46 PMsessionTokenFrontendDomain: ".domain.etx" to my session initialization. I know my connectionURI on the backend configuration is correct with the correct API key. I do have a custom supabase db, which my backend config is properly configured to work with.
My Next.JS API Folder Layout: 
/app/api/auth/[...path]/route.ts
My Next.JS App Dir Auth Folder
/app/auth
My app info:
js
export const appInfo = {
  appName: 'ApplicationName',
  apiDomain: "https://sub.domain.etx",
  websiteDomain: "https://sub.domain.etx",
  apiBasePath: "/api/auth",
  websiteBasePath: "/auth",
}rp_st
02/10/2024, 4:32 AMrp_st
02/10/2024, 4:33 AMa_tree.
02/10/2024, 4:41 PMcookies().getAll() function does not have any cookies, which I now realize is my issue. I was sure Next.JS automatically set server pages to be dynamically rendered whenever I implement the cookies import and it should've shown cookies just fine, but I guess this isn't the case?
For your second question,
Handling sessions during SSR is similar to how the documentation and GitHub both describe.a_tree.
02/10/2024, 4:41 PMjs
// ...imports
ensureSuperTokensInit();
async function getSSRSessionHelper(): Promise<{ session: SessionContainer | undefined; hasToken: boolean; hasInvalidClaims: boolean, error: Error | undefined }> {
    let session: SessionContainer | undefined;
    let hasToken = false;
    let hasInvalidClaims = false;
    let error: Error | undefined = undefined;
    try {
        ({ session, hasToken, hasInvalidClaims } = await getSSRSession(cookies().getAll(), headers()));
    } catch (err: any) {
        error = err;
    }
    return { session, hasToken, hasInvalidClaims, error };
}
export default async function DashboardLayout({
    children,
}: {
    children: React.ReactNode;
}) {
    const { session, hasToken, hasInvalidClaims, error } = await getSSRSessionHelper();
    if (error) {
        return (
            <div>
                Something went wrong while trying to get the session. Error - {error.message}
            </div>
        )
    }
    if (!session) {
        if (!hasToken) {
        // Note that this is triggered often.
            console.log("Redirecting to auth")
            return redirect("https://sub.domain.etx/auth");
        }
        if (hasInvalidClaims) {
            console.log("Redirecting to SessionAuthForNextJS")
            return <SessionAuthForNextJS />;
        } else {
            console.log("Redirecting to tryRefreshComponent")
            return <TryRefreshComponent />;
        }
    }
    /*
 
    Some fetch logic...
    */
    return (
        <SessionAuthForNextJS>
            <div className="text-white">
        {/* ...PageInformation */}
        </div>
    </SessionAuthForNextJS>
    );
}a_tree.
02/10/2024, 4:41 PMjs
if (request.nextUrl.pathname.includes("/dashboard") || request.nextUrl.pathname.includes("/account") || request.nextUrl.pathname.includes("/admin")) {
    return withSession(request, async (err, session) => {
      console.log(session);
      if (err) {
        console.log("Had a verification frontend error", err);
        return NextResponse.redirect("https://sub.domain.etx/auth")
      }
      if (session === undefined) {
        console.log("Session is undefined");
        return NextResponse.next();
      }
      console.log("Continuing with headers")
      return NextResponse.next({
        headers: {
          ...requestHeaders,
          "x-user-id": session.getUserId(),
        },
      });
    });
  }rp_st
02/10/2024, 5:24 PMa_tree.
02/10/2024, 5:55 PMrp_st
02/10/2024, 5:55 PMSuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).
Powered by