advance
This commit is contained in:
8
lib/supabase/middleware.ts
Normal file → Executable file
8
lib/supabase/middleware.ts
Normal file → Executable 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: (
|
||||
|
||||
Reference in New Issue
Block a user