refactor(auth): replace import path for getAuthHeaders with auth function in product routes

This commit is contained in:
Nils-Johan Gynther
2026-04-19 17:34:34 +02:00
parent 16703bb8eb
commit c970a5805f
2 changed files with 18 additions and 2 deletions
+9 -1
View File
@@ -1,7 +1,15 @@
import { getAuthHeaders } from '../../lib/auth-headers'; import { auth } from '../../auth';
const API_BASE = process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080'; const API_BASE = process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080';
async function getAuthHeaders(): Promise<Record<string, string>> {
const session = await auth();
if (!session?.accessToken) {
return {};
}
return { Authorization: `Bearer ${session.accessToken}` };
}
export async function POST(req: Request) { export async function POST(req: Request) {
try { try {
const body = await req.json(); const body = await req.json();
@@ -1,7 +1,15 @@
import { getAuthHeaders } from '../../lib/auth-headers'; import { auth } from '../../../auth';
const API_BASE = process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080'; const API_BASE = process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080';
async function getAuthHeaders(): Promise<Record<string, string>> {
const session = await auth();
if (!session?.accessToken) {
return {};
}
return { Authorization: `Bearer ${session.accessToken}` };
}
export async function PATCH( export async function PATCH(
req: Request, req: Request,
{ params }: { params: { id: string } }, { params }: { params: { id: string } },