mirror of https://gitlab.com/curben/blog
fix(cf-worker): properly set Headers
This commit is contained in:
parent
0b55a37381
commit
fd4c2043a6
|
@ -101,10 +101,8 @@ export default {
|
||||||
const { readable, writable } = new TransformStream()
|
const { readable, writable } = new TransformStream()
|
||||||
const { status, statusText } = response
|
const { status, statusText } = response
|
||||||
|
|
||||||
const htmlHeader = new Headers({
|
const htmlHeader = new Headers(request.headers)
|
||||||
...Object.fromEntries(request.headers),
|
if (!/text\/html/.test(accept)) htmlHeader.append('Accept', 'text/html')
|
||||||
Accept: 'text/html'
|
|
||||||
})
|
|
||||||
const page404 = new Request('https://mdleom.com/404', {
|
const page404 = new Request('https://mdleom.com/404', {
|
||||||
headers: htmlHeader
|
headers: htmlHeader
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
export async function onRequestGet (context) {
|
export async function onRequestGet (context) {
|
||||||
const { pathname } = new URL(context.request.url)
|
const { pathname } = new URL(context.request.url)
|
||||||
const imageURL = new URL(pathname, 'https://mdleom.com')
|
const imageURL = new URL(pathname, 'https://mdleom.com')
|
||||||
const headers = new Headers({
|
const headers = new Headers(context.request.headers)
|
||||||
...Object.fromEntries(context.request.headers),
|
headers.set('Host', 'mdleom.com')
|
||||||
'Host': 'mdleom.com'
|
|
||||||
})
|
|
||||||
const imageRequest = new Request(imageURL, {
|
const imageRequest = new Request(imageURL, {
|
||||||
headers
|
headers
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue