123
This commit is contained in:
@ -1,12 +1,16 @@
|
||||
import { createServerClient, type CookieOptions } from '@supabase/ssr';
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
// Placeholders only for build when env is missing; production must set env before build
|
||||
const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL || 'https://placeholder.supabase.co';
|
||||
const SUPABASE_ANON_KEY = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || 'placeholder-anon-key';
|
||||
|
||||
export async function createServerSupabaseClient() {
|
||||
const cookieStore = await cookies();
|
||||
|
||||
return createServerClient(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||
SUPABASE_URL,
|
||||
SUPABASE_ANON_KEY,
|
||||
{
|
||||
cookies: {
|
||||
get(name: string) {
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import { createBrowserClient } from '@supabase/ssr';
|
||||
|
||||
// Placeholders only for build when env is missing; production must set env before build
|
||||
const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL || 'https://placeholder.supabase.co';
|
||||
const SUPABASE_ANON_KEY = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || 'placeholder-anon-key';
|
||||
|
||||
export function createClient() {
|
||||
return createBrowserClient(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
|
||||
);
|
||||
return createBrowserClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
}
|
||||
|
||||
// Singleton instance for client-side usage
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import { createServerClient, type CookieOptions } from '@supabase/ssr';
|
||||
import { NextResponse, type NextRequest } from 'next/server';
|
||||
|
||||
// Placeholders only for build when env is missing; production must set env before build
|
||||
const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL || 'https://placeholder.supabase.co';
|
||||
const SUPABASE_ANON_KEY = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || 'placeholder-anon-key';
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
let response = NextResponse.next({
|
||||
request: {
|
||||
@ -9,8 +13,8 @@ export async function middleware(request: NextRequest) {
|
||||
});
|
||||
|
||||
const supabase = createServerClient(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||
SUPABASE_URL,
|
||||
SUPABASE_ANON_KEY,
|
||||
{
|
||||
cookies: {
|
||||
get(name: string) {
|
||||
|
||||
Reference in New Issue
Block a user