You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Portfolio/src/pages/link/[location].tsx

23 lines
590 B

import { GetServerSideProps, NextPage } from "next";
import prisma from "@utils/prisma";
const LinkRedirectPage: NextPage = () => {
return <></>;
};
export const getServerSideProps: GetServerSideProps = async ({ params }) => {
const location = params?.location;
if (location === undefined || typeof location !== "string")
return { notFound: true };
const link = await prisma.link.findFirst({ where: { location } });
if (link === null) return { notFound: true };
return { redirect: { destination: link.remoteAddress, permanent: false } };
};
export default LinkRedirectPage;