N
Nuxt2y 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
// ...
})
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
// ...
}
export default async (context) => {
const isomorphicAuth = process.server ? withSSRContext({ req: context.req }).Auth : Auth
// ...
}
1 Reply
oemer
oemerOP2y ago
Is it useRequestEvent? Seems to contain all the information!
const { node: { req } } = useRequestEvent()
const { node: { req } } = useRequestEvent()
Want results from more Discord servers?
Add your server