-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvercel.ts
More file actions
122 lines (120 loc) · 4.13 KB
/
Copy pathvercel.ts
File metadata and controls
122 lines (120 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { type VercelConfig, routes } from '@vercel/config/v1';
import { CSP } from './src/lib/csp';
export const config: VercelConfig = {
framework: 'astro',
buildCommand: 'pnpm build',
installCommand: 'pnpm install --frozen-lockfile',
outputDirectory: 'dist',
redirects: [
// strip trailing slash
{ source: '/(.*)/', destination: '/$1', statusCode: 308 },
// legacy /feed → /rss.xml
{ source: '/feed', destination: '/rss.xml', statusCode: 308 },
// www → apex is configured at the project domain level (Vercel API
// PATCH /v9/projects/.../domains/www.kevinkiklee.io with redirect +
// redirectStatusCode), not here — `host` matchers in vercel.ts
// redirects are silently ignored by the edge.
],
headers: [
routes.header('/(.*)', [
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload',
},
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
{
key: 'Permissions-Policy',
// Defense-in-depth: explicitly disable every powerful API the
// platform exposes. A static blog has no need for any of these,
// so blocking them costs nothing and shrinks the attack surface
// if a third-party script is ever compromised.
value: [
'accelerometer=()',
'attribution-reporting=()',
'autoplay=()',
'bluetooth=()',
'browsing-topics=()',
'camera=()',
// CopyButton uses navigator.clipboard.writeText for same-origin
// code-block copies, so allow self only — never cross-origin.
'clipboard-read=()',
'clipboard-write=(self)',
'compute-pressure=()',
'display-capture=()',
'encrypted-media=()',
'fullscreen=()',
'gamepad=()',
'geolocation=()',
'gyroscope=()',
'hid=()',
'identity-credentials-get=()',
'idle-detection=()',
// FLoC's deprecated cohort signal. Setting `=()` is the documented
// opt-out even though the API was removed in Chrome 115.
'interest-cohort=()',
'keyboard-map=()',
'local-fonts=()',
'magnetometer=()',
'microphone=()',
'midi=()',
'payment=()',
'picture-in-picture=()',
'private-state-token-issuance=()',
'private-state-token-redemption=()',
'publickey-credentials-get=()',
'screen-wake-lock=()',
'serial=()',
'storage-access=()',
'sync-xhr=()',
'unload=()',
'usb=()',
'web-share=()',
'window-management=()',
'xr-spatial-tracking=()',
].join(', '),
},
{ key: 'Cross-Origin-Opener-Policy', value: 'same-origin' },
// Block hotlinking of our subresources (fonts, images, OG renders)
// from other origins. `same-origin` is the strictest setting that
// still allows our own pages to fetch them.
{ key: 'Cross-Origin-Resource-Policy', value: 'same-origin' },
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'Content-Security-Policy', value: CSP },
]),
routes.cacheControl('/_astro/(.*)', {
public: true,
maxAge: '1year',
immutable: true,
}),
routes.cacheControl('/fonts/(.*)', {
public: true,
maxAge: '1year',
immutable: true,
}),
routes.cacheControl('/api/og(.*)', {
public: true,
sMaxAge: '1year',
immutable: true,
staleWhileRevalidate: '1day',
}),
routes.cacheControl('/(rss\\.xml|feed\\.json|sitemap.*|llms\\.txt|llms-full\\.txt)', {
public: true,
maxAge: '10min',
sMaxAge: '1hour',
}),
routes.cacheControl('/posts/(.+)\\.md', {
public: true,
maxAge: '10min',
sMaxAge: '1hour',
staleWhileRevalidate: '1day',
}),
routes.cacheControl('/(.*)\\.html', {
public: true,
sMaxAge: '60s',
staleWhileRevalidate: '1day',
}),
],
crons: [{ path: '/api/refresh', schedule: '0 5 * * 1' }],
};
export default config;