Add cookies handling to send-test-email route
Some checks failed
Staging Build / build (push) Failing after 27s
Some checks failed
Staging Build / build (push) Failing after 27s
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user