alpha
Login
or
Join now
danielroe.dev
/
roe.dev
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
[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
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
fix: try setting `vary: accept`
author
Daniel Roe
date
1 month ago
(Jun 9, 2026, 9:49 AM +0100)
commit
c8e1e0b7
c8e1e0b70f6f1f25a102dc13e4253af1227b253e
parent
3c24a62c
3c24a62ca515a434c44adc8ccc4c47f823888555
+19
-5
2 changed files
Expand all
Collapse all
Unified
Split
modules
md-rewrite.ts
server
middleware
md-redirect.ts
+14
-2
modules/md-rewrite.ts
View file
Reviewed
···
18
18
const vcJSON = resolve(nitro.options.output.dir, 'config.json')
19
19
const vcConfig = JSON.parse(await readFile(vcJSON, 'utf8'))
20
20
21
21
-
// Rewrite requests with Accept: text/markdown to the .md version
22
22
-
// The home page needs special handling: / -> /index.md
21
21
+
// Rewrite requests with Accept: text/markdown to the .md version.
22
22
+
// The home page needs special handling: / -> /index.md. The Vary
23
23
+
// header entries below run first (via continue: true) so the edge
24
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
35
+
})
36
36
+
37
37
+
vcConfig.routes.unshift({
38
38
+
src: '^/$',
39
39
+
headers: { Vary: 'Accept' },
40
40
+
continue: true,
41
41
+
}, {
42
42
+
src: '^/(.+?)/?$',
43
43
+
headers: { Vary: 'Accept' },
44
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
View file
Reviewed
···
3
3
export default defineEventHandler(event => {
4
4
if (event.method !== 'GET') return
5
5
6
6
-
const accept = getRequestHeader(event, 'accept') || ''
7
7
-
if (!accept.includes('text/markdown')) return
8
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
10
+
11
11
+
appendResponseHeader(event, 'Vary', 'Accept')
12
12
+
13
13
+
const accept = getRequestHeader(event, 'accept') || ''
14
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)