This commit is contained in:
Marcelo
2026-02-17 00:07:00 +00:00
parent b7a86a2d1c
commit be4ca2ed78
92 changed files with 6850 additions and 1188 deletions

8
lib/supabase/middleware.ts Normal file → Executable file
View File

@@ -1,5 +1,6 @@
import { NextResponse, type NextRequest } from "next/server";
import { createServerClient, type CookieOptions } from "@supabase/ssr";
import { readSupabasePublicConfig } from "@/lib/supabase/config";
export type SessionSnapshot = {
response: NextResponse;
@@ -11,9 +12,8 @@ export type SessionSnapshot = {
export const updateSession = async (req: NextRequest): Promise<SessionSnapshot> => {
const response = NextResponse.next({ request: req });
const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
const anonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
if (!url || !anonKey) {
const config = readSupabasePublicConfig();
if (!config) {
return {
response,
isAuthed: false,
@@ -22,7 +22,7 @@ export const updateSession = async (req: NextRequest): Promise<SessionSnapshot>
};
}
const supabase = createServerClient(url, anonKey, {
const supabase = createServerClient(config.url, config.anonKey, {
cookies: {
getAll: () => req.cookies.getAll(),
setAll: (