redirect logged-in users from / to /videos
This commit is contained in:
parent
c4b16ebdc8
commit
d260c9b341
1 changed files with 20 additions and 4 deletions
|
|
@ -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 },
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue