mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
fix(nuxt3)!: preserve runtime-config structure for client-side (#4267)
This commit is contained in:
parent
0d5ec20a4b
commit
4d1a6ba6ce
@ -120,8 +120,12 @@ export function createNuxtApp (options: CreateOptions) {
|
|||||||
|
|
||||||
// Expose runtime config
|
// Expose runtime config
|
||||||
if (process.server) {
|
if (process.server) {
|
||||||
nuxtApp.provide('config', options.ssrContext.runtimeConfig.private)
|
nuxtApp.provide('config', options.ssrContext.runtimeConfig)
|
||||||
nuxtApp.payload.config = options.ssrContext.runtimeConfig.public
|
// Client's runtime-config
|
||||||
|
nuxtApp.payload.config = {
|
||||||
|
public: options.ssrContext.runtimeConfig.public,
|
||||||
|
app: options.ssrContext.runtimeConfig.app
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nuxtApp.provide('config', reactive(nuxtApp.payload.config))
|
nuxtApp.provide('config', reactive(nuxtApp.payload.config))
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ const getSPARenderer = cachedResult(async () => {
|
|||||||
ssrContext.nuxt = {
|
ssrContext.nuxt = {
|
||||||
serverRendered: false,
|
serverRendered: false,
|
||||||
config: {
|
config: {
|
||||||
...config.public,
|
public: config.public,
|
||||||
app: config.app
|
app: config.app
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,13 +84,12 @@ export default eventHandler(async (event) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize ssr context
|
// Initialize ssr context
|
||||||
const config = useRuntimeConfig()
|
|
||||||
const ssrContext = {
|
const ssrContext = {
|
||||||
url,
|
url,
|
||||||
event,
|
event,
|
||||||
req: event.req,
|
req: event.req,
|
||||||
res: event.res,
|
res: event.res,
|
||||||
runtimeConfig: { private: config, public: { ...config.public, app: config.app } },
|
runtimeConfig: useRuntimeConfig(),
|
||||||
noSSR: event.req.headers['x-nuxt-no-ssr'],
|
noSSR: event.req.headers['x-nuxt-no-ssr'],
|
||||||
|
|
||||||
error: ssrError,
|
error: ssrError,
|
||||||
|
Loading…
Reference in New Issue
Block a user