feat(19.3-04): shared site cache purge route POST /api/__site__/cache/purge
- server/lib/siteCachePurge.ts: authorizeSitePurge, purgeSiteRouteCache,
parseSitePurgeEvent (kinds: lower-case letters and underscores)
- the route reads runtimeConfig.siteCache.purgeToken
(NUXT_SITE_CACHE_PURGE_TOKEN), 404 when off or proxied, 401 unauthorized
- route rule '/api/__site__/**': { cache: false }
- sitePurge specs with sha256 pins of the two shared files
- version 0.2.0
This commit is contained in:
@@ -23,6 +23,13 @@ export default defineNuxtConfig({
|
||||
// from request input.
|
||||
apiBase: 'http://127.0.0.1:8096/_faq/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: '',
|
||||
},
|
||||
public: {
|
||||
faq: {
|
||||
// Same-origin base for browser fetches (NUXT_PUBLIC_FAQ_API_BASE).
|
||||
@@ -30,4 +37,12 @@ export default defineNuxtConfig({
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// 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 },
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user