Make Redirects.urlPrefix actually gate which route a code resolves under
resolveAndTrackRedirect() now filters on urlPrefix in addition to code, with each route.ts passing its own literal prefix — previously the field was admin-display-only, so a code marked "/sticker" in Payload silently kept resolving under /r/<code> too. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G5mssdCBir9kyXTmqBjV3h
This commit is contained in:
@@ -5,11 +5,12 @@ 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.
|
||||
// collection, matched by `code` + urlPrefix "/sticker") 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);
|
||||
const targetPath = await resolveAndTrackRedirect(code, "/sticker");
|
||||
|
||||
if (!targetPath || !targetPath.startsWith("/") || targetPath.startsWith("//")) {
|
||||
notFound();
|
||||
|
||||
Reference in New Issue
Block a user