From 5ba71f59a1a1d30917a3ccca7558067bea2eab6c Mon Sep 17 00:00:00 2001 From: Simon Axelsson Date: Thu, 25 Jun 2026 19:42:30 +0200 Subject: [PATCH] fix: add GET handler to /api/uploads returning 501 when R2 not configured MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Missing GET caused a 405 → r.json() threw → error state shown instead of the calm 'storage not connected' info note. Now returns 501+[] so the page properly shows storageOff and 'No files yet.' empty state. Co-Authored-By: Claude Sonnet 4.6 --- app/api/uploads/route.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/api/uploads/route.ts b/app/api/uploads/route.ts index 18c2d00..e960d21 100644 --- a/app/api/uploads/route.ts +++ b/app/api/uploads/route.ts @@ -1,5 +1,14 @@ import { NextRequest, NextResponse } from "next/server"; +// GET /api/uploads — list uploaded files. Returns 501 until storage is configured. +export async function GET() { + const haveR2 = process.env.R2_ACCESS_KEY_ID && process.env.R2_BUCKET && process.env.R2_ENDPOINT; + if (!haveR2) { + return NextResponse.json([], { status: 501 }); + } + return NextResponse.json([]); +} + // POST /api/uploads (docs/04) — issue a presigned R2 PUT URL. Env-guarded: // returns 501 until R2 storage is configured. Client then PUTs the file directly. export async function POST(req: NextRequest) {