From 44c30fa1a16f79e82c7a5a1d9dac41d85ef29b84 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Thu, 18 Dec 2025 22:42:45 -0500 Subject: [PATCH] fix: correct print layout URL and separate preview from download MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed print-layout API to return correct URL format (?print=true instead of /print) - Modified print endpoint to only force download when &download=true is added - Updated create page and share page to use download parameter for download button - Print preview now renders properly as an image 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- web/app/api/print-layout/route.ts | 2 +- web/app/api/zine/[id]/route.ts | 20 +++++++++++++------- web/app/create/page.tsx | 2 +- web/app/z/[id]/ZineViewer.tsx | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/web/app/api/print-layout/route.ts b/web/app/api/print-layout/route.ts index 0f16fe4..90ea0d4 100644 --- a/web/app/api/print-layout/route.ts +++ b/web/app/api/print-layout/route.ts @@ -45,7 +45,7 @@ export async function POST(request: NextRequest) { return NextResponse.json({ success: true, - printLayoutUrl: `/api/zine/${zineId}/print`, + printLayoutUrl: `/api/zine/${zineId}?print=true`, filename: `${zineName || "mycrozine"}_print.png`, }); } catch (error) { diff --git a/web/app/api/zine/[id]/route.ts b/web/app/api/zine/[id]/route.ts index cf2d221..029f855 100644 --- a/web/app/api/zine/[id]/route.ts +++ b/web/app/api/zine/[id]/route.ts @@ -62,13 +62,19 @@ export async function GET(request: NextRequest, context: RouteContext) { } const printBuffer = await readFileAsBuffer(printPath); - return new NextResponse(new Uint8Array(printBuffer), { - headers: { - "Content-Type": "image/png", - "Content-Disposition": `attachment; filename="${id}_print.png"`, - "Cache-Control": "public, max-age=31536000, immutable", - }, - }); + const downloadParam = url.searchParams.get("download"); + + const headers: Record = { + "Content-Type": "image/png", + "Cache-Control": "public, max-age=31536000, immutable", + }; + + // Only add Content-Disposition for explicit downloads + if (downloadParam === "true") { + headers["Content-Disposition"] = `attachment; filename="${id}_print.png"`; + } + + return new NextResponse(new Uint8Array(printBuffer), { headers }); } // Return zine metadata diff --git a/web/app/create/page.tsx b/web/app/create/page.tsx index b54b72d..fbfb06c 100644 --- a/web/app/create/page.tsx +++ b/web/app/create/page.tsx @@ -621,7 +621,7 @@ export default function CreatePage() { {/* Actions */}
{zine.printLayoutUrl && (