fix: redirect to 404 on mii and profile not found
This commit is contained in:
parent
49c6206623
commit
ed33993a42
2 changed files with 7 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
import { auth } from "@/lib/auth";
|
import { auth } from "@/lib/auth";
|
||||||
import { prisma } from "@/lib/prisma";
|
import { prisma } from "@/lib/prisma";
|
||||||
|
|
@ -37,6 +38,8 @@ export default async function MiiPage({ params }: Props) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!mii) redirect("/404");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-2 max-sm:flex-col">
|
<div className="flex gap-2 max-sm:flex-col">
|
||||||
<Carousel images={mii?.images && mii?.images.length > 0 ? mii?.images : ["/missing.webp"]} className="shadow-lg" />
|
<Carousel images={mii?.images && mii?.images.length > 0 ? mii?.images : ["/missing.webp"]} className="shadow-lg" />
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { prisma } from "@/lib/prisma";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
import { prisma } from "@/lib/prisma";
|
||||||
import MiiList from "@/app/components/mii-list";
|
import MiiList from "@/app/components/mii-list";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
@ -19,6 +20,8 @@ export default async function ProfilePage({ params, searchParams }: Props) {
|
||||||
|
|
||||||
const likedMiis = await prisma.like.count({ where: { userId: Number(slug) } });
|
const likedMiis = await prisma.like.count({ where: { userId: Number(slug) } });
|
||||||
|
|
||||||
|
if (!user) redirect("/404");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="flex gap-4 mb-2">
|
<div className="flex gap-4 mb-2">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue