Replace createServerClient with createClient in multiple files (#30)

The `createServerClient` function has been replaced with the `createClient` function in the `server-actions.client.ts`, `route-handler.client.ts`, and `server-component.client.ts` files. This includes adding necessary import statements for `createClient` and adjusting the options passed to it, including `persistSession`, `detectSessionInUrl`, and `autoRefreshToken`.
This commit is contained in:
Giancarlo Buomprisco
2024-05-29 09:33:43 +07:00
committed by GitHub
parent cbf116c688
commit 7f4bfb15e5
5 changed files with 27 additions and 19 deletions

View File

@@ -3,6 +3,8 @@ import 'server-only';
import { unstable_noStore as noStore } from 'next/cache';
import { cookies } from 'next/headers';
import { createClient } from '@supabase/supabase-js';
import type { CookieOptions } from '@supabase/ssr';
import { createServerClient } from '@supabase/ssr';
@@ -31,11 +33,12 @@ export function getSupabaseRouteHandlerClient<GenericSchema = Database>(
if (params.admin) {
warnServiceRoleKeyUsage();
return createServerClient<GenericSchema>(keys.url, serviceRoleKey, {
return createClient<GenericSchema>(keys.url, serviceRoleKey, {
auth: {
persistSession: false,
autoRefreshToken: false,
detectSessionInUrl: false,
},
cookies: {},
});
}

View File

@@ -3,6 +3,8 @@ import 'server-only';
import { unstable_noStore as noStore } from 'next/cache';
import { cookies } from 'next/headers';
import { createClient } from '@supabase/supabase-js';
import { createServerClient } from '@supabase/ssr';
import { Database } from '../database.types';
@@ -35,11 +37,12 @@ export function getSupabaseServerActionClient<
if (admin) {
warnServiceRoleKeyUsage();
return createServerClient<GenericSchema>(keys.url, serviceRoleKey, {
return createClient<GenericSchema>(keys.url, serviceRoleKey, {
auth: {
persistSession: false,
detectSessionInUrl: false,
autoRefreshToken: false,
},
cookies: {},
});
}

View File

@@ -3,6 +3,8 @@ import 'server-only';
import { unstable_noStore as noStore } from 'next/cache';
import { cookies } from 'next/headers';
import { createClient } from '@supabase/supabase-js';
import { createServerClient } from '@supabase/ssr';
import { Database } from '../database.types';
@@ -30,12 +32,12 @@ export function getSupabaseServerComponentClient<GenericSchema = Database>(
if (params.admin) {
warnServiceRoleKeyUsage();
return createServerClient<GenericSchema>(keys.url, serviceRoleKey, {
return createClient<GenericSchema>(keys.url, serviceRoleKey, {
auth: {
persistSession: false,
autoRefreshToken: false,
detectSessionInUrl: false,
},
cookies: {},
});
}