-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.js
40 lines (33 loc) · 995 Bytes
/
routes.js
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
import { CustomCacheKey, Router } from '@edgio/core'
import { isProductionBuild } from '@edgio/core/environment'
const paths = ['/', '/cv', '/blogs', '/storyblok', '/about', '/blog/:path', '/showcase/:path']
const router = new Router()
router.match('/api/:path*', ({ setResponseHeader }) => {
setResponseHeader('Access-Control-Allow-Origin', 'https://rishi.app')
})
if (isProductionBuild()) {
paths.forEach((i) => {
router.match(i, ({ cache, removeUpstreamResponseHeader }) => {
removeUpstreamResponseHeader('cache-control')
cache({
edge: {
maxAgeSeconds: 60,
staleWhileRevalidateSeconds: 60 * 60 * 24 * 365,
},
key: new CustomCacheKey().excludeAllQueryParameters(),
})
})
})
router.static('dist/client')
}
router.match('/_image', ({ cache }) => {
cache({
edge: {
maxAgeSeconds: 60 * 60 * 24 * 365,
},
})
})
router.fallback(({ renderWithApp }) => {
renderWithApp()
})
export default router