import { commentImage, getCommentViewer } from "@/lib/comments/repository"; import { publicMediaUrl } from "@/lib/media/storage"; import { errorResponse } from "@/lib/security/http"; export async function GET(_request: Request, context: { params: Promise<{ id: string }> }) { try { const image = await commentImage((await context.params).id, await getCommentViewer()); // Keep old attachment links working without proxying image bytes through the app. return new Response(null, { status: 307, headers: { Location: publicMediaUrl(image.objectKey), "Cache-Control": "private, no-store", } }); } catch (cause) { return errorResponse(cause); } }