You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Track hash-mode OG URLs whose source page isn't in the prerender graph.
34
+
// These 404 at context.ts because the page's defineOgImage() never ran so
35
+
// the hash:<hash> cache entry was never written. Clear the error so the build
36
+
// doesn't fail, and warn once at the end of prerender so users can investigate.
37
+
constorphanedOgHashes: string[]=[]
38
+
nitro.hooks.hook('prerender:route',(route)=>{
39
+
if(!route.error||route.error.statusCode!==404)
40
+
return
41
+
if(!route.route.includes('/_og/s/o_'))
42
+
return
43
+
orphanedOgHashes.push(route.route)
44
+
route.error=undefined
45
+
route.contents=''
46
+
route.fileName=undefined
47
+
})
48
+
49
+
nitro.hooks.hook('prerender:done',async()=>{
50
+
if(orphanedOgHashes.length>0){
51
+
logger.warn(
52
+
`Skipped ${orphanedOgHashes.length} orphaned OG image hash URL${orphanedOgHashes.length>1 ? 's' : ''} during prerender. `
53
+
+`These URLs were crawled from HTML but their source page was not prerendered, so the hash cache entry was never written. `
54
+
+`If your pages are prerendered but OG images are generated at runtime, enable \`security.strict\` with a \`security.secret\` to switch to signed dynamic URLs.`,
0 commit comments