2
0

🚑 (auth) Fix bad requests with getSession on server side

This commit is contained in:
Baptiste Arnaud
2023-04-03 16:42:10 +02:00
parent b96a3a6a8e
commit 49071b73b6
39 changed files with 112 additions and 91 deletions

View File

@ -1,15 +1,16 @@
import { getSession } from 'next-auth/react'
import { NextPageContext } from 'next'
import { GetServerSidePropsContext } from 'next'
import { User } from '@typebot.io/prisma'
import { isNotDefined } from '@typebot.io/lib'
import { sign } from 'jsonwebtoken'
import { getServerSession } from 'next-auth'
import { authOptions } from './api/auth/[...nextauth]'
export default function Page() {
return null
}
export async function getServerSideProps(context: NextPageContext) {
const session = await getSession(context)
export async function getServerSideProps(context: GetServerSidePropsContext) {
const session = await getServerSession(context.req, context.res, authOptions)
if (isNotDefined(session?.user))
return {
redirect: {