fix(cf-pages): rewrite host header

This commit is contained in:
Ming Di Leom 2024-10-06 20:52:38 +00:00
parent 64a29d95a0
commit ab2bca0b64
No known key found for this signature in database
GPG Key ID: 32D3E28E96A695E8
1 changed files with 5 additions and 1 deletions

View File

@ -1,8 +1,12 @@
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({
...context.request.headers,
'Host': 'mdleom.com'
})
const imageRequest = new Request(imageURL, { const imageRequest = new Request(imageURL, {
headers: context.request.headers headers
}) })
// return fetch(imageRequest) // return fetch(imageRequest)