forked from gifhuppp/hazmee003
-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.js
41 lines (35 loc) · 1.21 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
// This file was added by layer0 init.
// You should commit this file to source control.
const { Router } = require('@layer0/core/router')
const ONE_HOUR = 60 * 60
const ONE_DAY = 24 * ONE_HOUR
const ONE_YEAR = 365 * ONE_DAY
const edgeOnly = {
browser: false,
edge: { maxAgeSeconds: ONE_YEAR },
}
const edgeAndBrowser = {
browser: { maxAgeSeconds: ONE_YEAR },
edge: { maxAgeSeconds: ONE_YEAR },
}
module.exports = new Router()
.prerender([{ path: '/' }])
// match routes for js/css resources and serve the static files
.match('/static/:path*', ({ serveStatic, cache }) => {
cache(edgeAndBrowser)
serveStatic('build/static/:path*')
})
// match client-side routes that aren't a static asset
// and serve the app shell. client-side router will
// handle the route once it is rendered
.match('/:path*/:file([^\\.]+|)', ({ appShell, cache }) => {
cache(edgeOnly)
appShell('build/index.html')
})
// match other assets such as favicon, manifest.json, etc
.match('/:path*', ({ serveStatic, cache }) => {
cache(edgeOnly)
serveStatic('build/:path*')
})
// send any unmatched request to serve the static index.html
.fallback(({ serveStatic }) => serveStatic('build/index.html'))