fix(nuxt): set config on ssrContext in spa renderer (#20216)

This commit is contained in:
Daniel Roe 2023-04-11 23:33:21 +01:00 committed by GitHub
parent 8f67d871b8
commit fe2800540c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -124,13 +124,13 @@ const getSPARenderer = lazyCachedFunction(async () => {
ssrContext!.payload = { ssrContext!.payload = {
_errors: {}, _errors: {},
serverRendered: false, serverRendered: false,
config: {
public: config.public,
app: config.app
},
data: {}, data: {},
state: {} state: {}
} }
ssrContext.config = {
public: config.public,
app: config.app
}
ssrContext!.renderMeta = ssrContext!.renderMeta ?? getStaticRenderedHead ssrContext!.renderMeta = ssrContext!.renderMeta ?? getStaticRenderedHead
return Promise.resolve(result) return Promise.resolve(result)
} }

View File

@ -46,6 +46,7 @@ describe('route rules', () => {
const { script, attrs } = parseData(await $fetch('/route-rules/spa')) const { script, attrs } = parseData(await $fetch('/route-rules/spa'))
expect(script.serverRendered).toEqual(false) expect(script.serverRendered).toEqual(false)
expect(attrs['data-ssr']).toEqual('false') expect(attrs['data-ssr']).toEqual('false')
await expectNoClientErrors('/route-rules/spa')
}) })
it('test noScript routeRules', async () => { it('test noScript routeRules', async () => {

View File

@ -1,5 +1,5 @@
export default defineNuxtPlugin((nuxtApp) => { export default defineNuxtPlugin((nuxtApp) => {
if (nuxtApp.payload.blinkable !== '<revivified-blink>') { if (nuxtApp.payload.serverRendered && nuxtApp.payload.blinkable !== '<revivified-blink>') {
throw createError({ throw createError({
message: 'Custom type in Nuxt payload was not revived correctly' message: 'Custom type in Nuxt payload was not revived correctly'
}) })