From aa8b699a944f94a08d7059eca9d4d3d66c7f1a51 Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Mon, 4 Sep 2023 11:20:24 -0700 Subject: [PATCH] fix: set headers after setResponse in Fetch handler (#8828) --- packages/request/src/fetch.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/request/src/fetch.ts b/packages/request/src/fetch.ts index cf0d390e892..0be505c2fbb 100644 --- a/packages/request/src/fetch.ts +++ b/packages/request/src/fetch.ts @@ -38,12 +38,13 @@ const _fetch: typeof fetch = const Fetch = { async request(context: Context) { const response = await _fetch(context.request.url!, context.request); - context.setResponse(response); if (!response.headers.has('date')) { response.headers.set('date', new Date().toUTCString()); } + context.setResponse(response); + // if we are an error, we will want to throw if (!response.ok || response.status >= 400) { const text = await response.text();