This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathroutes.js
76 lines (67 loc) · 2 KB
/
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
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
import { nextRoutes } from '@layer0/next';
import { Router } from '@layer0/core/router';
// import { NEXT_CACHE_HANDLER, SSR_CACHE_HANDLER } from './cache.js'
// Create a new router
const router = new Router()
// router.prerender([
// // Cache handler
// NEXT_CACHE_HANDLER,
// SSR_CACHE_HANDLER,
//
// ])
// Serve service worker
router.get('/service-worker.js', ({ serviceWorker }) => {
return serviceWorker('.next/static/service-worker.js')
})
router.get('/event/:eventId', ({cache}) => {
cache({
browser: {
maxAgeSeconds: 0,
},
edge: {
maxAgeSeconds: 10,
staleWhileRevalidateSeconds: 7 * 24 * 60 * 60,
},
})
})
.get('/_next/data/:__build__/event/:eventId.json', ({cache}) => {
cache({
browser: {
maxAgeSeconds: 0,
serviceWorkerSeconds: 10,
},
edge: {
maxAgeSeconds: 10,
staleWhileRevalidateSeconds: 7 * 24 * 60 * 60,
},
})
})
// SSR Cache Handler
// router.match('/', SSR_CACHE_HANDLER)
// router.match('/show/:path*', SSR_CACHE_HANDLER)
// Cache fonts
// router.match('/fonts/:file', ({ cache, serveStatic }) => {
// cache(assetCache)
// serveStatic('public/fonts/:file')
// })
// router.match('/assets/:file', ({ cache, serveStatic }) => {
// cache(assetCache)
// serveStatic('public/assets/:file')
// })
// router.match('/image/:path*', ({ cache, setResponseHeader, proxy }) => {
// cache(assetCache)
// setResponseHeader('cache-control', 'public, max-age=86400')
// proxy('image', { path: ':path*' })
// })
// router.match('/_next/image/:path*', ({ cache, setResponseHeader, removeUpstreamResponseHeader }) => {
// removeUpstreamResponseHeader('set-cookie')
// setResponseHeader('cache-control', 'public, max-age=86400')
// cache(assetCache)
// })
// Next Cache Handler
// router.match('/_next/data/:build/index.json', NEXT_CACHE_HANDLER)
// router.match('/_next/data/:build/show/:name.json', NEXT_CACHE_HANDLER)
// Default Next.js Routes
router.use(nextRoutes)
// eslint-disable-next-line no-undef
module.exports = router