( ctx: GetServerSidePropsContext, )
| 2 | import { createServerSupabaseClient } from "@supabase/auth-helpers-nextjs"; |
| 3 | |
| 4 | export 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 | }; |
no outgoing calls
no test coverage detected