Next.js Discord

Discord Forum

middleware composition

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
I'm using authjs middleware and I want to put some custom logic to run beside it.
is this code correct?
import NextAuth from 'next-auth';
import authConfig from './auth.config';
import { NextRequest, NextResponse } from 'next/server';

export const { auth } = NextAuth(authConfig);
export const middleware = async (request: NextRequest) => {
  console.log('current path', request.nextUrl.pathname);
  await auth();
  return NextResponse.next();
};

0 Replies