mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
fix(renderer): deep merge runtimeConfig for server (#8856)
This commit is contained in:
parent
5346963585
commit
1b9a9d6449
@ -103,7 +103,7 @@ export default async (ssrContext) => {
|
||||
__webpack_public_path__ = joinURL(ssrContext.nuxt.config.app.cdnURL, ssrContext.nuxt.config.app.assetsPath)
|
||||
}
|
||||
// Create the app definition and the instance (created for each request)
|
||||
const { app, router<%= (store ? ', store' : '') %> } = await createApp(ssrContext, { ...ssrContext.runtimeConfig.public, ...ssrContext.runtimeConfig.private })
|
||||
const { app, router<%= (store ? ', store' : '') %> } = await createApp(ssrContext, ssrContext.runtimeConfig.private)
|
||||
const _app = new Vue(app)
|
||||
// Add ssr route path to nuxt context so we can account for page navigation between ssr and csr
|
||||
ssrContext.nuxt.routePath = app.context.route.path
|
||||
|
@ -4,6 +4,7 @@ import consola from 'consola'
|
||||
import { template } from 'lodash'
|
||||
import { TARGETS, isModernRequest, urlJoin, waitFor } from '@nuxt/utils'
|
||||
import { normalizeURL } from 'ufo'
|
||||
import defu from 'defu'
|
||||
|
||||
import SPARenderer from './renderers/spa'
|
||||
import SSRRenderer from './renderers/ssr'
|
||||
@ -296,7 +297,7 @@ export default class VueRenderer {
|
||||
|
||||
// Set runtime config on renderContext
|
||||
renderContext.runtimeConfig = {
|
||||
private: renderContext.spa ? {} : { ...this.options.privateRuntimeConfig },
|
||||
private: renderContext.spa ? {} : defu(this.options.privateRuntimeConfig, this.options.publicRuntimeConfig),
|
||||
public: { ...this.options.publicRuntimeConfig }
|
||||
}
|
||||
|
||||
|
11
test/fixtures/runtime-config/nuxt.config.js
vendored
11
test/fixtures/runtime-config/nuxt.config.js
vendored
@ -2,12 +2,19 @@ export default {
|
||||
publicRuntimeConfig: {
|
||||
baseURL: process.env.BASE_URL,
|
||||
isFixture: true,
|
||||
TOKEN: 'default'
|
||||
TOKEN: 'default',
|
||||
nested: {
|
||||
priv: 0,
|
||||
pub: 1
|
||||
}
|
||||
},
|
||||
privateRuntimeConfig: {
|
||||
baseURL: '${PUBLIC_URL}${BASE_URL}',
|
||||
API_SECRET: '',
|
||||
FOO: '123/${FOO}'
|
||||
FOO: '123/${FOO}',
|
||||
nested: {
|
||||
priv: 1
|
||||
}
|
||||
},
|
||||
serverMiddleware: [
|
||||
(req, _, next) => {
|
||||
|
Loading…
Reference in New Issue
Block a user