Question Details

No question body available.

Tags

vue.js nuxt.js nuxt-middleware

Answers (1)

Accepted Answer Available
Accepted Answer
August 17, 2025 Score: 2 Rep: 144 Quality: Medium Completeness: 50%

I was able to solve this by wrapping the logic within an import.meta.client if statement. Composables are available only on the client side, hence it couldn't resolve it on SSR.

This worked for me.

export default defineNuxtRouteMiddleware(async () => {

// Do this only on the client side if (import.meta.client) { const newSession = await useNewSession() const accessToken = newSession.access_token

const { data, error } = await useFetch('/api/organization', { headers: { 'Authorization': Bearer ${accessToken} }, })

if (error.value) { throw error }

const organizationCookie = useCookie('af-organization') organizationCookie.value = JSON.stringify(data.value) } })