fix(nuxt3): keep nuxtApp instance in client-side (#2114)

This commit is contained in:
pooya parsa 2021-11-23 18:50:20 +01:00 committed by GitHub
parent 650f14bc42
commit 7e5e50bba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -180,7 +180,10 @@ export const setNuxtAppInstance = (nuxt: NuxtApp | null) => {
export function callWithNuxt<T extends () => any> (nuxt: NuxtApp, setup: T) {
setNuxtAppInstance(nuxt)
const p: ReturnType<T> = setup()
if (process.server) {
// Unset nuxt instance to prevent context-sharing in server-side
setNuxtAppInstance(null)
}
return p
}