Next.js Discord

Discord Forum

nothing logging in middleware

Unanswered
Gharial posted this in #help-forum
Open in Discord
GharialOP
I cant seem to do any logging in my middleware
export const setUserLocale: MiddlewareFactory = next => {
  console.log('this works.')

  return async (request: NextRequest, event: NextFetchEvent): Promise<NextResponse> => {
    console.log('but this doesnt')

    return next(request, event)
  }
}

My middleware factory is defined in types
export type ChainableMiddleware = (request: NextRequest, event: NextFetchEvent) => Promise<NextResponse>
export type MiddlewareFactory = (middleware: ChainableMiddleware) => ChainableMiddleware

Does anyone know why i can't get the second log to display?

1 Reply

Polar bear
What are you trying to do?

We need more context before we can be helpful. Can you show how you're using the setUserLocale function?