From 0b55a3738128689247b54454f1226eea194a8502 Mon Sep 17 00:00:00 2001 From: Ming Di Leom <2809763-curben@users.noreply.gitlab.com> Date: Sun, 6 Oct 2024 21:04:46 +0000 Subject: [PATCH] fix(cf-worker): parse Headers as key value object https://stackoverflow.com/a/72415727 --- cf-images/index.js | 2 +- functions/images/[[catchall]].js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cf-images/index.js b/cf-images/index.js index d071bca..f4bbf8b 100644 --- a/cf-images/index.js +++ b/cf-images/index.js @@ -102,7 +102,7 @@ export default { const { status, statusText } = response const htmlHeader = new Headers({ - ...request.headers, + ...Object.fromEntries(request.headers), Accept: 'text/html' }) const page404 = new Request('https://mdleom.com/404', { diff --git a/functions/images/[[catchall]].js b/functions/images/[[catchall]].js index 7069269..5c5275e 100644 --- a/functions/images/[[catchall]].js +++ b/functions/images/[[catchall]].js @@ -2,7 +2,7 @@ export async function onRequestGet (context) { const { pathname } = new URL(context.request.url) const imageURL = new URL(pathname, 'https://mdleom.com') const headers = new Headers({ - ...context.request.headers, + ...Object.fromEntries(context.request.headers), 'Host': 'mdleom.com' }) const imageRequest = new Request(imageURL, {