- runtimeConfig.siteCache.allowProxied (NUXT_SITE_CACHE_ALLOW_PROXIED, default false) lets the shared purge route accept a request that came through a TLS-terminating proxy; the bearer token is then the only gate - shared lib, route and spec stay byte-identical across the three layers, with updated sha256 pins and two new sitePurge specs - version 0.3.0
55 lines
2.2 KiB
TypeScript
55 lines
2.2 KiB
TypeScript
// vue-menu-layer: renders a menu of the SummerCMS menu plugin
|
|
// (GET /_menu/api/v1/menus/{code}) as an accessible site navigation. An app
|
|
// consumes it with `extends: ['vue-menu-layer']` and renders <MenuNav>.
|
|
//
|
|
// Every path below is absolute and built from this file's directory: a
|
|
// relative or ~ path in a layer config resolves against the consuming
|
|
// project, not the layer. The layer declares no Nuxt modules.
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const currentDir = fileURLToPath(new URL('.', import.meta.url))
|
|
|
|
export default defineNuxtConfig({
|
|
compatibilityDate: '2025-07-15',
|
|
devtools: { enabled: false },
|
|
|
|
// Tokens first, then the neutral styles that use them. The app's own css
|
|
// array loads after these, so its token overrides win.
|
|
css: [`${currentDir}app/assets/css/menu-tokens.css`, `${currentDir}app/assets/css/menu-base.css`],
|
|
|
|
runtimeConfig: {
|
|
menu: {
|
|
// Server-only base for SSR fetches (NUXT_MENU_API_BASE). It never
|
|
// comes from request input.
|
|
apiBase: 'http://127.0.0.1:8096/_menu/api/v1',
|
|
},
|
|
siteCache: {
|
|
// Server-only bearer token of the shared site cache purge route
|
|
// POST /api/__site__/cache/purge (NUXT_SITE_CACHE_PURGE_TOKEN), the
|
|
// backend's site_cache.purge_token. Shorter than 32 characters, the
|
|
// route answers 404.
|
|
purgeToken: '',
|
|
// NUXT_SITE_CACHE_ALLOW_PROXIED: set it to true when the backend reaches
|
|
// the site through a TLS-terminating proxy (an https site_cache.purge_url
|
|
// on another host), which adds X-Forwarded-For, X-Real-IP or Forwarded.
|
|
// The route then accepts proxied requests and the bearer token is the
|
|
// only gate; unset, it answers 404 to any proxied request.
|
|
allowProxied: false,
|
|
},
|
|
public: {
|
|
menu: {
|
|
// Same-origin base for browser fetches (NUXT_PUBLIC_MENU_API_BASE).
|
|
apiBase: '/_menu/api/v1',
|
|
},
|
|
},
|
|
},
|
|
|
|
// The shared site routes are never route-cached. Nitro wraps every
|
|
// handler matching an app rule such as '/**': { swr } in its cached
|
|
// handler, which keys by path, does not skip POST and hides request
|
|
// headers, so the purge route would answer from the cache without running.
|
|
routeRules: {
|
|
'/api/__site__/**': { cache: false },
|
|
},
|
|
})
|