From 6e4417050356990d3d4a1c3080f69d1e95047cf0 Mon Sep 17 00:00:00 2001 From: Inkcha Date: Mon, 27 Jul 2026 19:32:00 -0400 Subject: [PATCH] fix: /api returns JSON 404 instead of HTML for unmatched routes The /api directory previously had a page.tsx that rendered an HTML API documentation page at the /api URL. This caused API consumers making requests to undefined endpoints to receive 28KB of HTML instead of a proper JSON error response. Changes: - Moved API docs from /api to /api-docs - Created catch-all route at /api/[[...slug]] returning JSON 404 - All previously working API routes remain unchanged --- apps/web/app/{api => api-docs}/page.tsx | 0 apps/web/app/api/[[...slug]]/route.ts | 38 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+) rename apps/web/app/{api => api-docs}/page.tsx (100%) create mode 100644 apps/web/app/api/[[...slug]]/route.ts diff --git a/apps/web/app/api/page.tsx b/apps/web/app/api-docs/page.tsx similarity index 100% rename from apps/web/app/api/page.tsx rename to apps/web/app/api-docs/page.tsx diff --git a/apps/web/app/api/[[...slug]]/route.ts b/apps/web/app/api/[[...slug]]/route.ts new file mode 100644 index 0000000..92bdbbb --- /dev/null +++ b/apps/web/app/api/[[...slug]]/route.ts @@ -0,0 +1,38 @@ +import { NextResponse } from "next/server"; + +export const runtime = "edge"; + +export async function GET() { + return NextResponse.json( + { error: "Not found. See /api-docs for API documentation." }, + { status: 404 }, + ); +} + +export async function POST() { + return NextResponse.json( + { error: "Not found. See /api-docs for API documentation." }, + { status: 404 }, + ); +} + +export async function PUT() { + return NextResponse.json( + { error: "Not found. See /api-docs for API documentation." }, + { status: 404 }, + ); +} + +export async function PATCH() { + return NextResponse.json( + { error: "Not found. See /api-docs for API documentation." }, + { status: 404 }, + ); +} + +export async function DELETE() { + return NextResponse.json( + { error: "Not found. See /api-docs for API documentation." }, + { status: 404 }, + ); +}