From 32bcd0ec36fe1cfed52a7faebdbf0bd7dd205d38 Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Sat, 24 May 2025 15:46:07 +0100 Subject: [PATCH] fix: stop double redirect on 'random mii' button --- src/app/random/{route.ts => page.tsx} | 10 +--------- src/components/random-link.tsx | 3 +-- 2 files changed, 2 insertions(+), 11 deletions(-) rename src/app/random/{route.ts => page.tsx} (60%) diff --git a/src/app/random/route.ts b/src/app/random/page.tsx similarity index 60% rename from src/app/random/route.ts rename to src/app/random/page.tsx index 79c8a9b..bd19881 100644 --- a/src/app/random/route.ts +++ b/src/app/random/page.tsx @@ -1,14 +1,7 @@ -import { NextRequest } from "next/server"; import { redirect } from "next/navigation"; - import { prisma } from "@/lib/prisma"; -import { RateLimit } from "@/lib/rate-limit"; - -export async function GET(request: NextRequest) { - const rateLimit = new RateLimit(request, 20); - const check = await rateLimit.handle(); - if (check) return check; +export default async function RandomPage() { const count = await prisma.mii.count(); if (count === 0) redirect("/"); @@ -20,6 +13,5 @@ export async function GET(request: NextRequest) { }); if (!randomMii) redirect("/"); - redirect(`/mii/${randomMii.id}`); } diff --git a/src/components/random-link.tsx b/src/components/random-link.tsx index 2e5923e..959a6a4 100644 --- a/src/components/random-link.tsx +++ b/src/components/random-link.tsx @@ -1,12 +1,11 @@ "use client"; import Link from "next/link"; -import { redirect } from "next/navigation"; import { Icon } from "@iconify/react"; export default function RandomLink() { return ( - redirect("/random")} className="pill button !p-0 h-full aspect-square" data-tooltip="Go to a Random Mii"> + );