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 = {
_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)
}

View File

@ -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 () => {

View File

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