From 9aa14f1bf721a58e91e4d93132b2ad4d4b6f52a3 Mon Sep 17 00:00:00 2001 From: Dhravya Date: Sat, 13 Aug 2022 12:45:13 +0530 Subject: [PATCH] added redirect --- src/pages/index.tsx | 30 ++++++++++++++++-------------- tsconfig.json | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 58333fc..1b91e60 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,19 +1,21 @@ -import React from 'react' -import {useSession} from "next-auth/react" -import { useRouter } from 'next/router' +import React, { useEffect } from "react"; +import { useSession } from "next-auth/react"; +import { useRouter } from "next/router"; +import { NextPageContext } from "next"; function Index() { - const session = useSession() - const router = useRouter() + return
LMFAO
; +} + +export async function getServerSideProps(context: NextPageContext) { + // TODO: redirect to website if user is not logged in - // TODO: @yxshv pls lol - // If user is logged in, redirect to /home. - // otherwise, redirect to what-is.lmfao.tech - return ( -
- LMFAO -
- ) + return { + redirect: { + destination: "/home", + permanent: false, + }, + }; } -export default Index \ No newline at end of file +export default Index; diff --git a/tsconfig.json b/tsconfig.json index b1a52cf..59d55ef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,6 +20,6 @@ "incremental": true, "noUncheckedIndexedAccess": true }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "src/hooks/_middlware.js"], "exclude": ["node_modules"] }