fix: stop double redirect on 'random mii' button
This commit is contained in:
parent
045308dcef
commit
32bcd0ec36
2 changed files with 2 additions and 11 deletions
|
|
@ -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}`);
|
||||
}
|
||||
|
|
@ -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 (
|
||||
<Link href={"/random"} onClick={() => redirect("/random")} className="pill button !p-0 h-full aspect-square" data-tooltip="Go to a Random Mii">
|
||||
<Link href={"/random"} className="pill button !p-0 h-full aspect-square" data-tooltip="Go to a Random Mii">
|
||||
<Icon icon="mdi:dice-3" fontSize={28} />
|
||||
</Link>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue