// GET /api/__seo__/site: the CMS's site answer (GET /site, SEO // plugin v0.2.0) through the layer's server and its cache, for useSeoSite() // on the server and in the browser. Always 200 with {site: | null}: // null with the layer off, with a backend before v0.2.0 (its /site answers // 404) or with a backend that has not answered since start. Never // route-cached ('/api/__seo__/**' cache false) and never indexed. import { seoServerConfig } from '../../lib/config.ts' import { siteAnswer } from '../../lib/site.ts' export default defineEventHandler(async (event) => { setResponseHeaders(event, { 'cache-control': 'no-store', 'x-robots-tag': 'noindex' }) const cfg = seoServerConfig(useRuntimeConfig(event)) if (!cfg.enabled) return { site: null } const forwarded = event.context.seoForwardedFor as string | undefined const state = await siteAnswer(cfg, forwarded ? { 'x-forwarded-for': forwarded } : {}) return { site: state.state === 'ok' ? state.site : null } })