123
This commit is contained in:
@ -1,12 +1,16 @@
|
|||||||
import { createServerClient, type CookieOptions } from '@supabase/ssr';
|
import { createServerClient, type CookieOptions } from '@supabase/ssr';
|
||||||
import { cookies } from 'next/headers';
|
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() {
|
export async function createServerSupabaseClient() {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
|
|
||||||
return createServerClient(
|
return createServerClient(
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
SUPABASE_URL,
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
SUPABASE_ANON_KEY,
|
||||||
{
|
{
|
||||||
cookies: {
|
cookies: {
|
||||||
get(name: string) {
|
get(name: string) {
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
import { createBrowserClient } from '@supabase/ssr';
|
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() {
|
export function createClient() {
|
||||||
return createBrowserClient(
|
return createBrowserClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Singleton instance for client-side usage
|
// Singleton instance for client-side usage
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
import { createServerClient, type CookieOptions } from '@supabase/ssr';
|
import { createServerClient, type CookieOptions } from '@supabase/ssr';
|
||||||
import { NextResponse, type NextRequest } from 'next/server';
|
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) {
|
export async function middleware(request: NextRequest) {
|
||||||
let response = NextResponse.next({
|
let response = NextResponse.next({
|
||||||
request: {
|
request: {
|
||||||
@ -9,8 +13,8 @@ export async function middleware(request: NextRequest) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const supabase = createServerClient(
|
const supabase = createServerClient(
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
SUPABASE_URL,
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
SUPABASE_ANON_KEY,
|
||||||
{
|
{
|
||||||
cookies: {
|
cookies: {
|
||||||
get(name: string) {
|
get(name: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user