Add cookies handling to smtp-settings routes
Some checks failed
Staging Build / build (push) Failing after 1m55s
Some checks failed
Staging Build / build (push) Failing after 1m55s
This commit is contained in:
@@ -1,11 +1,29 @@
|
|||||||
// API route for getting and updating SMTP settings (protected by admin check)
|
// API route for getting and updating SMTP settings (protected by admin check)
|
||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from 'next/server';
|
||||||
import { createServerClient } from '@supabase/ssr';
|
import { createServerClient } from '@supabase/ssr';
|
||||||
|
import { cookies } from 'next/headers';
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: { session } } = await supabase.auth.getSession();
|
const { data: { session } } = await supabase.auth.getSession();
|
||||||
@@ -25,10 +43,28 @@ export async function GET() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: Request) {
|
||||||
const supabase = createServerClient(
|
const cookieStore = await cookies();
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL ?? '',
|
|
||||||
process.env.SUPABASE_SERVICE_ROLE_KEY ?? ''
|
const supabase = createServerClient(
|
||||||
);
|
process.env.NEXT_PUBLIC_SUPABASE_URL ?? '',
|
||||||
|
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
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const { data: { session } } = await supabase.auth.getSession();
|
const { data: { session } } = await supabase.auth.getSession();
|
||||||
if (!session) {
|
if (!session) {
|
||||||
|
|||||||
Reference in New Issue
Block a user