From b4280f020ea12df354cab6dbb1309eab6ed774e7 Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Sat, 18 Apr 2026 09:50:47 +0200 Subject: [PATCH] fix(route): update parameter type for PATCH function and correct image directory handling --- frontend/app/api/admin-users/[id]/route.ts | 6 +++--- frontend/app/api/images/[filename]/route.ts | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/app/api/admin-users/[id]/route.ts b/frontend/app/api/admin-users/[id]/route.ts index 35b117af..a88717ab 100644 --- a/frontend/app/api/admin-users/[id]/route.ts +++ b/frontend/app/api/admin-users/[id]/route.ts @@ -6,16 +6,16 @@ const API_BASE = export async function PATCH( request: NextRequest, - { params }: { params: { id: string } }, + { params }: { params: Promise<{ id: string }> }, ) { + const { id } = await params; const session = await auth(); if (!session || (session.user as any)?.role !== 'admin') { return NextResponse.json({ message: 'Förbjuden' }, { status: 403 }); } const body = await request.json(); - const res = await fetch(`${API_BASE}/api/users/${params.id}/role`, { - method: 'PATCH', + const res = await fetch(`${API_BASE}/api/users/${id}/role`, { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${session.accessToken}`, diff --git a/frontend/app/api/images/[filename]/route.ts b/frontend/app/api/images/[filename]/route.ts index a7a87828..d4c21bc2 100644 --- a/frontend/app/api/images/[filename]/route.ts +++ b/frontend/app/api/images/[filename]/route.ts @@ -2,7 +2,8 @@ import { NextRequest, NextResponse } from 'next/server'; import * as fs from 'fs'; import * as path from 'path'; -const IMAGE_DIR = process.env.IMAGE_DIR || '/app/public/images'; +// turbopackIgnore: true — IMAGE_DIR är en runtime env-variabel, inte statisk sökväg +const IMAGE_DIR: string = /* turbopackIgnore: true */ (process.env.IMAGE_DIR || '/app/public/images') as string; export async function GET( _request: NextRequest, @@ -15,7 +16,7 @@ export async function GET( return new NextResponse('Not found', { status: 404 }); } - const filePath = path.join(/*turbopackIgnore: true*/ IMAGE_DIR, filename); + const filePath = path.join(IMAGE_DIR, filename); if (!fs.existsSync(filePath)) { return new NextResponse('Not found', { status: 404 });