NuxtN
Nuxt14mo ago
Zach

getting Nuxt context into a nitro route

Hey guys, I'm trying to create an adapter for our auth provider, logto, and it's proving to be a bit more difficult than I expected. Originally I was accessing our logto context via nuxtApp.ssrContext?.event.context.logtoClient

unfortunately this doesn't work client sided, as you might expect, so I decided to create a nitro route for client requests to go through.

import type LogtoClient from "@logto/node";

export default defineEventHandler(async () => {
    const nuxtApp = useNuxtApp();
    const logtoClient = nuxtApp.ssrContext?.event.context.logtoClient as LogtoClient
    ...


Unfortunately, I found out I can't access nuxtApp in nitro routes. Does anyone know how I can get that injected context into a nitro route?
Was this page helpful?