Skip to content

Commit ac97010

Browse files
committed
fix: undo recent tests
1 parent da2551d commit ac97010

File tree

3 files changed

+15
-36
lines changed

3 files changed

+15
-36
lines changed

src/hooks.server.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type Handle, redirect } from "@sveltejs/kit"
22
import { createServerClient } from "@supabase/ssr"
33
import { sequence } from "@sveltejs/kit/hooks"
4-
import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_LOCAL_SUPABASE_URL } from "$env/static/public"
4+
import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from "$env/static/public"
55
import type { Database } from "$lib/types/supabase"
66

77
const redirects: Handle = async ({ event, resolve }) => {
@@ -21,27 +21,16 @@ const redirects: Handle = async ({ event, resolve }) => {
2121
}
2222

2323
const supabase: Handle = async ({ event, resolve }) => {
24-
event.locals.supabaseServer = createServerClient<Database>(
25-
PUBLIC_LOCAL_SUPABASE_URL,
26-
PUBLIC_SUPABASE_ANON_KEY,
27-
{
28-
cookies: {
29-
getAll: () => event.cookies.getAll(),
30-
setAll: (cookiesToSet) => {
31-
cookiesToSet.forEach(({ name, value, options }) => {
32-
event.cookies.set(name, value, { ...options, path: "/" })
33-
})
34-
}
35-
},
36-
global: {
37-
fetch: (input: string | URL | Request, init?: RequestInit) => {
38-
console.log("Server hook: ", input)
39-
40-
return event.fetch(input, init)
41-
}
24+
event.locals.supabaseServer = createServerClient<Database>(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, {
25+
cookies: {
26+
getAll: () => event.cookies.getAll(),
27+
setAll: (cookiesToSet) => {
28+
cookiesToSet.forEach(({ name, value, options }) => {
29+
event.cookies.set(name, value, { ...options, path: "/" })
30+
})
4231
}
4332
}
44-
)
33+
})
4534

4635
event.locals.safeGetSession = async () => {
4736
const start = performance.now()

src/lib/server/supabase.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { SUPABASE_SERVICE_KEY } from "$env/static/private"
2-
import { PUBLIC_LOCAL_SUPABASE_URL } from "$env/static/public"
2+
import { PUBLIC_SUPABASE_URL } from "$env/static/public"
33
import type { Database } from "$lib/types/supabase"
44
import { formatError } from "$lib/utils"
55
import { type SupabaseClient, createClient, type Provider } from "@supabase/supabase-js"
66
import { error, redirect } from "@sveltejs/kit"
77

8-
export const supabaseAdmin = createClient<Database>(PUBLIC_LOCAL_SUPABASE_URL, SUPABASE_SERVICE_KEY, {
8+
export const supabaseAdmin = createClient<Database>(PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_KEY, {
99
auth: { autoRefreshToken: true, persistSession: false }
1010
})
1111

src/routes/+layout.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createBrowserClient, createServerClient, isBrowser } from "@supabase/ssr"
2-
import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, PUBLIC_LOCAL_SUPABASE_URL } from "$env/static/public"
2+
import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from "$env/static/public"
33
import type { Session, User } from "@supabase/supabase-js"
44

55
export const load = async ({ data, depends, fetch }) => {
@@ -8,20 +8,10 @@ export const load = async ({ data, depends, fetch }) => {
88

99
const supabaseClient = isbrowser
1010
? createBrowserClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, {
11-
global: {
12-
fetch: (input: string | URL | Request, init?: RequestInit) => {
13-
console.log("Layout Client: ", input)
14-
return fetch(input, init)
15-
}
16-
}
11+
global: { fetch }
1712
})
18-
: createServerClient(PUBLIC_LOCAL_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, {
19-
global: {
20-
fetch: (input: string | URL | Request, init?: RequestInit) => {
21-
console.log("Layout Server: ", input)
22-
return fetch(input, init)
23-
}
24-
},
13+
: createServerClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, {
14+
global: { fetch },
2515
cookies: {
2616
getAll() {
2717
return data.cookies

0 commit comments

Comments
 (0)