2024-10-06 20:45:26 +00:00
|
|
|
export async function onRequestGet (context) {
|
|
|
|
const { pathname } = new URL(context.request.url)
|
|
|
|
const imageURL = new URL(pathname, 'https://mdleom.com')
|
2024-10-06 20:52:38 +00:00
|
|
|
const headers = new Headers({
|
|
|
|
...context.request.headers,
|
|
|
|
'Host': 'mdleom.com'
|
|
|
|
})
|
2024-10-06 20:45:26 +00:00
|
|
|
const imageRequest = new Request(imageURL, {
|
2024-10-06 20:52:38 +00:00
|
|
|
headers
|
2024-10-06 20:45:26 +00:00
|
|
|
})
|
2024-10-06 20:06:16 +00:00
|
|
|
// return fetch(imageRequest)
|
2024-10-06 20:21:01 +00:00
|
|
|
|
|
|
|
// CF_IMAGES binds to cf-images worker
|
|
|
|
// configured in the pages dashboard
|
2024-10-06 20:45:26 +00:00
|
|
|
return context.env.CF_IMAGES.fetch(imageRequest)
|
2024-10-06 20:06:16 +00:00
|
|
|
}
|