mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 15:42:09 +00:00
fix(nuxt3): don't mock server-only properties on client-side (#2376)
This commit is contained in:
parent
3e82f0f2cb
commit
c87c692ddb
@ -114,6 +114,12 @@ const todo = new Set<keyof LegacyContext | keyof LegacyContext['ssrContext']>([
|
|||||||
'beforeSerialize'
|
'beforeSerialize'
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const serverProperties = new Set<keyof LegacyContext['ssrContext'] | keyof LegacyContext>([
|
||||||
|
'req',
|
||||||
|
'res',
|
||||||
|
'ssrContext'
|
||||||
|
])
|
||||||
|
|
||||||
const routerKeys: Array<keyof LegacyContext | keyof LegacyContext['ssrContext']> = ['route', 'params', 'query']
|
const routerKeys: Array<keyof LegacyContext | keyof LegacyContext['ssrContext']> = ['route', 'params', 'query']
|
||||||
|
|
||||||
const staticFlags = {
|
const staticFlags = {
|
||||||
@ -159,6 +165,10 @@ export const legacyPlugin = (nuxtApp: NuxtApp) => {
|
|||||||
return staticFlags[p]
|
return staticFlags[p]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.client && serverProperties.has(p)) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
if (p === 'ssrContext') {
|
if (p === 'ssrContext') {
|
||||||
return nuxt._legacyContext
|
return nuxt._legacyContext
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user