MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / pageGetServerSideProps

Function pageGetServerSideProps

components/getServerSideProps.ts:4–36  ·  view source on GitHub ↗
(
  ctx: GetServerSidePropsContext,
)

Source from the content-addressed store, hash-verified

2import { createServerSupabaseClient } from "@supabase/auth-helpers-nextjs";
3
4export const pageGetServerSideProps = async (
5 ctx: GetServerSidePropsContext,
6) => {
7 // Create authenticated Supabase Client
8 const supabase = createServerSupabaseClient(ctx);
9
10 // Check if we have a session
11 const {
12 data: { session },
13 } = await supabase.auth.getSession();
14
15 if (!session) {
16 const { query } = ctx;
17 let redirectPath = "/sign-in";
18 if (query) {
19 const params = new URLSearchParams(query as Record<string, any>);
20 redirectPath += `/?${params}`;
21 }
22 return {
23 redirect: {
24 // Below redirects, taking into account the join_id
25 destination: redirectPath,
26 permanent: false,
27 },
28 };
29 }
30
31 return {
32 props: {
33 initialSession: session,
34 },
35 };
36};

Callers 2

getServerSidePropsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected