diff --git a/app/api/missions/[missionId]/route.ts b/app/api/missions/[missionId]/route.ts index dc245fc4..ee24b61b 100644 --- a/app/api/missions/[missionId]/route.ts +++ b/app/api/missions/[missionId]/route.ts @@ -160,12 +160,34 @@ export async function PUT(request: Request, props: { params: Promise<{ missionId volunteers } = body; + // Process logo URL to get relative path + let logoPath = logo; + if (logo && typeof logo === 'string') { + try { + // If it's a full URL, extract the path + if (logo.startsWith('http')) { + const url = new URL(logo); + logoPath = url.pathname.startsWith('/') ? url.pathname.substring(1) : url.pathname; + } + // If it's already a relative path, ensure it starts with 'missions/' + else if (!logo.startsWith('missions/')) { + logoPath = `missions/${logo}`; + } + } catch (error) { + console.error('Error processing logo URL:', { + error, + logo, + missionId + }); + } + } + // Update the mission data const updatedMission = await (prisma as any).mission.update({ where: { id: missionId }, data: { name, - logo, + logo: logoPath, oddScope: oddScope || undefined, niveau, intention,