redirect logged-in users from / to /videos

This commit is contained in:
MarconLP 2023-04-20 00:39:03 +02:00
parent c4b16ebdc8
commit d260c9b341
No known key found for this signature in database
GPG key ID: A08A9C8B623F5EA5

View file

@ -1,9 +1,8 @@
import { type NextPage } from "next";
import { GetServerSideProps, type NextPage } from "next";
import Head from "next/head";
import { signIn, signOut, useSession } from "next-auth/react";
import { getSession } from "next-auth/react";
import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/outline";
import { api } from "~/utils/api";
import { Dialog } from "@headlessui/react";
import { useState } from "react";
import Link from "next/link";
@ -188,4 +187,21 @@ const Home: NextPage = () => {
);
};
export default Home;
export default Home;
export const getServerSideProps: GetServerSideProps = async (context) => {
const session = await getSession(context);
if (session) {
return {
redirect: {
destination: "/videos",
permanent: false,
},
};
}
return {
props: { session },
};
};