feat: vue-seo-layer, the Nuxt half of the SummerCMS SEO plugin

This commit is contained in:
Jakub Zych
2026-10-31 13:45:37 +01:00
commit ac59f3c80d
30 changed files with 7962 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
// Keeps the visitor's address available to route-cached SSR renders.
//
// An app rule such as `'/**': { swr }` renders cached pages from a copy of
// the request without headers. The SEO API throttles per client address,
// so forwarding only the Nuxt peer would put every cache miss in one bucket.
// The event context is shared with that copy, so the incoming
// x-forwarded-for plus the peer address is recorded here, before the cached
// handler runs, and resolveSeo and the 404 report forward it.
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('request', (event) => {
const forwarded = [getRequestHeader(event, 'x-forwarded-for'), event.node.req.socket?.remoteAddress]
.filter((v): v is string => typeof v === 'string' && v !== '')
.join(', ')
event.context.seoForwardedFor = forwarded
})
})