Add cookies handling to send-test-email route
Some checks failed
Staging Build / build (push) Failing after 27s

This commit is contained in:
DanielS
2026-06-23 00:26:08 +02:00
parent e97ff51dc8
commit bab2930b97

View File

@@ -2,11 +2,29 @@
import { NextResponse } from 'next/server'; import { NextResponse } from 'next/server';
import { sendMail } from '@/utils/mail'; import { sendMail } from '@/utils/mail';
import { createServerClient } from '@supabase/ssr'; import { createServerClient } from '@supabase/ssr';
import { cookies } from 'next/headers';
export async function POST(request: Request) { export async function POST(request: Request) {
const cookieStore = await cookies();
const supabase = createServerClient( const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL ?? '', process.env.NEXT_PUBLIC_SUPABASE_URL ?? '',
process.env.SUPABASE_SERVICE_ROLE_KEY ?? '' process.env.SUPABASE_SERVICE_ROLE_KEY ?? '',
{
cookies: {
getAll() {
return cookieStore.getAll()
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) =>
cookieStore.set(name, value, options)
)
} catch {
// Kann in einer API-Route ignoriert werden, wenn nur gelesen wird
}
},
},
}
); );
// Verify admin rights expecting a user with role "admin" in the "users" table // Verify admin rights expecting a user with role "admin" in the "users" table