Files
avbeat-com/src/lib/supabase/client.tsx
Local Administrator 25abc55da1 feat(avbeat): point forum + auth at av schema, swap newsletter chips to AV verticals
Schema wiring — AV Beat was inheriting a 'bb' default schema from the
original fork. Fixed three call sites so the AV Beat app reads/writes
the av schema unless an explicit NEXT_PUBLIC_SUPABASE_SCHEMA override
is set:
  - src/lib/supabase/client.tsx:8 default 'bb' -> 'av'
  - src/lib/supabase/server.tsx:11 default 'bb' -> 'av'
  - src/app/api/auth/lookup-email/route.ts :31 + :42 hardcoded
    .schema('bb') -> .schema('av') so signup lookup hits the
    AV-side subscriber tables, not BB's.

Newsletter signup — homepage chips were the BB taxonomy ('Broadcast',
'Post Production', 'Animation', 'AI & Automation', 'Live Production',
'NAB Show'). Swapped for pro-AV verticals that align with the new
forum categories: Conference Rooms & UC, Digital Signage, Live Events
& Staging, Displays & LED, Audio, AV over IP, InfoComm & ISE.
Default selected flipped from 'Broadcast' to 'Conference Rooms & UC'
so the form doesn't pre-select a non-existent value.
2026-06-03 14:39:12 +00:00

36 lines
1.6 KiB
TypeScript

import { createBrowserClient } from '@supabase/ssr';
export function createClient() {
return createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
db: { schema: process.env.NEXT_PUBLIC_SUPABASE_SCHEMA || 'av' },
cookies: {
getAll() {
if (typeof document === 'undefined') return [];
return document.cookie.split(';').map((cookie) => {
const [name, ...rest] = cookie.trim().split('=');
return { name, value: decodeURIComponent(rest.join('=')) };
});
},
setAll(cookiesToSet: Array<{ name: string; value: string; options?: any }>) {
if (typeof document === 'undefined') return;
cookiesToSet.forEach(({ name, value, options }) => {
// Match server-side cookie attributes. Server uses Next.js
// cookies().set(), which defaults to SameSite=Lax with no
// Secure flag. Writing the same cookie name with different
// SameSite/Secure from JS produces conflicting state in the
// browser cookie store and breaks AuthContext on /contributor.
let cookieString = `${name}=${encodeURIComponent(value)}; Path=${options?.path || '/'}; SameSite=Lax`;
if (options?.maxAge) cookieString += `; max-age=${options.maxAge}`;
if (options?.domain) cookieString += `; domain=${options.domain}`;
if (options?.expires) cookieString += `; expires=${options.expires}`;
document.cookie = cookieString;
});
},
},
}
);
}