fix(nuxt): allow disabling early hints (#8264)

This commit is contained in:
Daniel Roe 2022-10-17 21:20:13 +01:00 committed by GitHub
parent a90b303d97
commit 96a8807abf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -99,6 +99,7 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
},
replace: {
'process.env.NUXT_NO_SSR': nuxt.options.ssr === false,
'process.env.NUXT_EARLY_HINTS': nuxt.options.experimental.writeEarlyHints !== false,
'process.env.NUXT_NO_SCRIPTS': !!nuxt.options.experimental.noScripts && !nuxt.options.dev,
'process.env.NUXT_INLINE_STYLES': !!nuxt.options.experimental.inlineSSRStyles,
'process.env.NUXT_PAYLOAD_EXTRACTION': !!nuxt.options.experimental.payloadExtraction,

View File

@ -157,7 +157,7 @@ export default defineRenderHandler(async (event) => {
const renderer = (process.env.NUXT_NO_SSR || ssrContext.noSSR) ? await getSPARenderer() : await getSSRRenderer()
// Render 103 Early Hints
if (!isRenderingPayload && !process.env.prerender) {
if (process.env.NUXT_EARLY_HINTS && !isRenderingPayload && !process.env.prerender) {
const { link } = renderResourceHeaders({}, renderer.rendererContext)
writeEarlyHints(event, link)
}

View File

@ -81,6 +81,9 @@ export default defineUntypedSchema({
payloadExtraction: true,
/** Enable cross-origin prefetch using the Speculation Rules API. */
crossOriginPrefetch: false
crossOriginPrefetch: false,
/** Write early hints when using node server */
writeEarlyHints: true
}
})