* Update navigation menu text color and disable caching in Supabase clients Updated the active and hover text colors for the navigation menu in the UI package. Also, added prevention of any sort of caching in the Supabase clients (server-actions.client.ts, route-handler.client.ts, server-component.client.ts) to be eventually removed in Next v15. Automatic token refresh is also turned off in the server-component client. * Increase content items limit in docs loader The content items limit in the documentation loader has been increased to the maximum safe integer. This ensures that all documentation entries are retrieved from the CMS, avoiding any potential omissions due to arbitrary limits.
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import 'server-only';
|
|
|
|
import { unstable_noStore as noStore } from 'next/cache';
|
|
import { cookies } from 'next/headers';
|
|
|
|
import { createServerClient } from '@supabase/ssr';
|
|
|
|
import { Database } from '../database.types';
|
|
import {
|
|
getServiceRoleKey,
|
|
warnServiceRoleKeyUsage,
|
|
} from '../get-service-role-key';
|
|
import { getSupabaseClientKeys } from '../get-supabase-client-keys';
|
|
|
|
const keys = getSupabaseClientKeys();
|
|
const serviceRoleKey = getServiceRoleKey();
|
|
|
|
function createServerSupabaseClient<
|
|
GenericSchema extends Database = Database,
|
|
>() {
|
|
return createServerClient<GenericSchema>(keys.url, keys.anonKey, {
|
|
cookies: getCookiesStrategy(),
|
|
});
|
|
}
|
|
|
|
export function getSupabaseServerActionClient<
|
|
GenericSchema extends Database = Database,
|
|
>(params?: { admin: boolean }) {
|
|
// prevent any caching (to be removed in Next v15)
|
|
noStore();
|
|
|
|
const keys = getSupabaseClientKeys();
|
|
const admin = params?.admin ?? false;
|
|
|
|
if (admin) {
|
|
warnServiceRoleKeyUsage();
|
|
|
|
return createServerClient<GenericSchema>(keys.url, serviceRoleKey, {
|
|
auth: {
|
|
persistSession: false,
|
|
},
|
|
cookies: {},
|
|
});
|
|
}
|
|
|
|
return createServerSupabaseClient();
|
|
}
|
|
|
|
function getCookiesStrategy() {
|
|
const cookieStore = cookies();
|
|
|
|
return {
|
|
get: (name: string) => {
|
|
return cookieStore.get(name)?.value;
|
|
},
|
|
set: (name: string, value: string, options: object) => {
|
|
cookieStore.set({ name, value, ...options });
|
|
},
|
|
remove: (name: string, options: object) => {
|
|
cookieStore.set({
|
|
name,
|
|
value: '',
|
|
...options,
|
|
});
|
|
},
|
|
};
|
|
}
|