Add /sticker/[code] legacy QR redirect route + placeholder /sticker page

Mirrors app/r/[code]/route.ts's Payload Redirects lookup under the fixed
/sticker prefix already printed on existing sticker QR codes, so those
stay admin-editable/toggleable in the same collection instead of needing
a code-level static redirect.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G5mssdCBir9kyXTmqBjV3h
This commit is contained in:
Marco
2026-08-28 12:58:10 +00:00
parent bd1b73e304
commit e9b7a2f582
2 changed files with 78 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import { redirect, notFound } from "next/navigation";
import { NextRequest } from "next/server";
import { resolveAndTrackRedirect } from "../../lib/payload";
// Legacy sticker QR codes already printed as https://einfach-produktiv.com/sticker/<code>
// before the /r/[code] short-link scheme existed — can't be reprinted, so
// this mirrors app/r/[code]/route.ts's exact lookup (same Redirects
// collection, matched by `code`) under the fixed /sticker prefix instead.
// Keeps a single admin-editable/toggleable source of truth for both.
export async function GET(_request: NextRequest, { params }: { params: Promise<{ code: string }> }) {
const { code } = await params;
const targetPath = await resolveAndTrackRedirect(code);
if (!targetPath || !targetPath.startsWith("/") || targetPath.startsWith("//")) {
notFound();
}
redirect(targetPath);
}