diff --git a/packages/vue-app/template/server.js b/packages/vue-app/template/server.js index ac343b84c4..37cd351516 100644 --- a/packages/vue-app/template/server.js +++ b/packages/vue-app/template/server.js @@ -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 diff --git a/packages/vue-renderer/src/renderer.js b/packages/vue-renderer/src/renderer.js index 80b5ba1f19..1c87c3c38c 100644 --- a/packages/vue-renderer/src/renderer.js +++ b/packages/vue-renderer/src/renderer.js @@ -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 } } diff --git a/test/fixtures/runtime-config/nuxt.config.js b/test/fixtures/runtime-config/nuxt.config.js index 744ffda64c..0eec93abea 100644 --- a/test/fixtures/runtime-config/nuxt.config.js +++ b/test/fixtures/runtime-config/nuxt.config.js @@ -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) => {