From fe2800540c9a3c9d921707e17e74b4ea4747853f Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 11 Apr 2023 23:33:21 +0100 Subject: [PATCH] fix(nuxt): set config on `ssrContext` in spa renderer (#20216) --- packages/nuxt/src/core/runtime/nitro/renderer.ts | 8 ++++---- test/basic.test.ts | 1 + .../basic/plugins/custom-type-assertion.client.ts | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/nuxt/src/core/runtime/nitro/renderer.ts b/packages/nuxt/src/core/runtime/nitro/renderer.ts index 86dd6acf1d..3427b90b08 100644 --- a/packages/nuxt/src/core/runtime/nitro/renderer.ts +++ b/packages/nuxt/src/core/runtime/nitro/renderer.ts @@ -124,13 +124,13 @@ const getSPARenderer = lazyCachedFunction(async () => { ssrContext!.payload = { _errors: {}, serverRendered: false, - config: { - public: config.public, - app: config.app - }, data: {}, state: {} } + ssrContext.config = { + public: config.public, + app: config.app + } ssrContext!.renderMeta = ssrContext!.renderMeta ?? getStaticRenderedHead return Promise.resolve(result) } diff --git a/test/basic.test.ts b/test/basic.test.ts index 6394819149..18d3577205 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -46,6 +46,7 @@ describe('route rules', () => { const { script, attrs } = parseData(await $fetch('/route-rules/spa')) expect(script.serverRendered).toEqual(false) expect(attrs['data-ssr']).toEqual('false') + await expectNoClientErrors('/route-rules/spa') }) it('test noScript routeRules', async () => { diff --git a/test/fixtures/basic/plugins/custom-type-assertion.client.ts b/test/fixtures/basic/plugins/custom-type-assertion.client.ts index a7294f6159..b5f985d505 100644 --- a/test/fixtures/basic/plugins/custom-type-assertion.client.ts +++ b/test/fixtures/basic/plugins/custom-type-assertion.client.ts @@ -1,5 +1,5 @@ export default defineNuxtPlugin((nuxtApp) => { - if (nuxtApp.payload.blinkable !== '') { + if (nuxtApp.payload.serverRendered && nuxtApp.payload.blinkable !== '') { throw createError({ message: 'Custom type in Nuxt payload was not revived correctly' })