[READ-ONLY] Mirror of https://github.com/danielroe/roe.dev. This is the code and content for my personal website, built in Nuxt. roe.dev
0

Configure Feed

Select the types of activity you want to include in your feed.

fix: try setting `vary: accept`

+19 -5
+14 -2
modules/md-rewrite.ts
··· 18 18 const vcJSON = resolve(nitro.options.output.dir, 'config.json') 19 19 const vcConfig = JSON.parse(await readFile(vcJSON, 'utf8')) 20 20 21 - // Rewrite requests with Accept: text/markdown to the .md version 22 - // The home page needs special handling: / -> /index.md 21 + // Rewrite requests with Accept: text/markdown to the .md version. 22 + // The home page needs special handling: / -> /index.md. The Vary 23 + // header entries below run first (via continue: true) so the edge 24 + // cache keeps markdown and HTML entries distinct on both branches. 23 25 vcConfig.routes.unshift({ 24 26 src: '^/$', 25 27 dest: '/index.md', ··· 30 32 dest: '/$1.md', 31 33 has: [{ type: 'header', key: 'accept', value: '(.*)text/markdown(.*)' }], 32 34 check: true, 35 + }) 36 + 37 + vcConfig.routes.unshift({ 38 + src: '^/$', 39 + headers: { Vary: 'Accept' }, 40 + continue: true, 41 + }, { 42 + src: '^/(.+?)/?$', 43 + headers: { Vary: 'Accept' }, 44 + continue: true, 33 45 }) 34 46 35 47 await writeFile(vcJSON, JSON.stringify(vcConfig, null, 2), 'utf8')
+5 -3
server/middleware/md-redirect.ts
··· 3 3 export default defineEventHandler(event => { 4 4 if (event.method !== 'GET') return 5 5 6 - const accept = getRequestHeader(event, 'accept') || '' 7 - if (!accept.includes('text/markdown')) return 8 - 9 6 if (event.path.endsWith('.md')) return 10 7 11 8 const clean = event.path.replace(/\/$/, '') || '/' 12 9 if (!mdPages.has(clean)) return 10 + 11 + appendResponseHeader(event, 'Vary', 'Accept') 12 + 13 + const accept = getRequestHeader(event, 'accept') || '' 14 + if (!accept.includes('text/markdown')) return 13 15 14 16 const dest = clean === '/' ? '/index.md' : `${clean}.md` 15 17 return sendRedirect(event, dest, 302)