-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.js
30 lines (25 loc) · 795 Bytes
/
worker.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
import manifest from './dist/client/ssr-manifest.json'
import { render } from './dist/server/server.js'
import template from './dist/client/template.html'
globalThis.__VUE_OPTIONS_API__ = false
globalThis.__VUE_PROD_DEVTOOLS__ = false
async function handleRequest(request) {
const { pathname } = new URL(request.url)
const [readable, link] = await render(pathname, manifest, template)
return new Response(readable, {
headers: {
'content-type': 'text/html;charset=UTF-8',
'cache-control': 'no-cache',
link: `</inter.woff2>; rel=preload; as=font; crossorigin, ${link}`// 103 Early Hints 🚀
}
})
}
export default {
async fetch(request) {
try {
return handleRequest(request)
} catch (err) {
return new Response(err.message)
}
}
}