Add middleware

Took 1 hour 8 minutes
This commit is contained in:
Lucàs
2023-03-28 15:10:57 +02:00
parent 28be7ce223
commit caabf0ac7a
3 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ model Chat {
model Message { model Message {
id String @id @default(auto()) @map("_id") @db.ObjectId id String @id @default(auto()) @map("_id") @db.ObjectId
message String text String
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
+9
View File
@@ -0,0 +1,9 @@
export { default } from "next-auth/middleware"
export const config = {
matcher: [
"/dashboard",
"/profile",
'/chat/:path*'
]
}
+7
View File
@@ -41,6 +41,13 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) {
return await NextAuth(req, res, { return await NextAuth(req, res, {
providers, providers,
session: {strategy: 'jwt'}, session: {strategy: 'jwt'},
pages: {
signIn: '/login',
signOut: '/auth/signout',
error: '/auth/error',
verifyRequest: '/auth/verify-request',
newUser: '/auth/new-user' // New users will be directed here on first sign in (leave the property out if not of interest)
},
secret: process.env.NEXTAUTH_SECRET, secret: process.env.NEXTAUTH_SECRET,
callbacks: { callbacks: {
async session({session, token}: { session: any; token: any }) { async session({session, token}: { session: any; token: any }) {