-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
52 lines (48 loc) · 1.49 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
// This file was automatically added by layer0 deploy.
// You should commit this file to source control.
const { Router } = require('@layer0/core/router');
const { nextRoutes, renderNextPage } = require('@layer0/next');
const foreverEdge = {
browser: {
maxAgeSeconds: 0,
serviceWorkerSeconds: 60 * 60 * 24
},
edge: {
staleWhileRevalidateSeconds: 1,
maxAgeSeconds: 60 * 60 * 60 * 365
}
};
const assetCache = {
edge: {
maxAgeSeconds: 60 * 60 * 60 * 365,
forcePrivateCaching: true
},
browser: {
maxAgeSeconds: 0,
serviceWorkerSeconds: 60 * 60 * 24
}
};
let prerenderPages = ['/'];
module.exports = new Router()
.prerender(prerenderPages.map((page) => ({ path: page })))
.get('/sitemap.xml', (res) => {
renderNextPage('/sitemap.xml', res);
})
.match('/styles/:file', ({ cache, serveStatic }) => {
cache(assetCache);
serveStatic('styles/:file');
})
.match('/_next/static/:path*', ({ cache, removeUpstreamResponseHeader }) => {
removeUpstreamResponseHeader('set-cookie');
removeUpstreamResponseHeader('cache-control');
cache(foreverEdge);
})
.match('/_next/image/:path*', ({ cache, removeUpstreamResponseHeader }) => {
removeUpstreamResponseHeader('set-cookie');
removeUpstreamResponseHeader('cache-control');
cache(foreverEdge);
})
.match('/service-worker.js', ({ serviceWorker }) => {
return serviceWorker('.next/static/service-worker.js');
})
.use(nextRoutes); // automatically adds routes for all files under /pages