11import { type Handle , redirect } from "@sveltejs/kit"
22import { createServerClient } from "@supabase/ssr"
33import { sequence } from "@sveltejs/kit/hooks"
4- import { PUBLIC_SUPABASE_URL , PUBLIC_SUPABASE_ANON_KEY } from "$env/static/public"
4+ import { PUBLIC_SUPABASE_ANON_KEY , PUBLIC_LOCAL_SUPABASE_URL } from "$env/static/public"
55import type { Database } from "$lib/types/supabase"
66
77const redirects : Handle = async ( { event, resolve } ) => {
@@ -21,22 +21,27 @@ const redirects: Handle = async ({ event, resolve }) => {
2121}
2222
2323const supabase : Handle = async ( { event, resolve } ) => {
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- } )
31- }
32- } ,
33- global : {
34- fetch : ( input : string | URL | Request , init ?: RequestInit ) => {
35- console . log ( "Server hook: " , input )
36- return event . fetch ( input , init )
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+ }
3742 }
3843 }
39- } )
44+ )
4045
4146 event . locals . safeGetSession = async ( ) => {
4247 const start = performance . now ( )
0 commit comments