NuxtN
Nuxt3y ago
oemer

What is the replacement for `context.req` in a route middleware in nuxt 3?

I have an
auth
middleware, where I need the
req
when it's on the server.
I have this kind of logic:

export default defineNuxtRouteMiddleware(async (to, from) => {
  const isomorphicAuth = process.server ? withSSRContext({ req: /* ??? */ }).Auth : Auth
  // ...
})

But in a route middleware you only have
to
and
from


In Nuxt 2 it worked like this:
export default async (context) => {
  const isomorphicAuth = process.server ? withSSRContext({ req: context.req }).Auth : Auth
  // ...
}
Was this page helpful?