From ffee7e3336709bba6bb80e004fac5555cc69b1f0 Mon Sep 17 00:00:00 2001 From: nelsonprsousa Date: Tue, 5 Nov 2024 10:35:54 +0000 Subject: [PATCH] fix: Do not remove Cache-Control end user defined header value --- .changeset/moaning-master-chief.md | 5 +++++ .../src/middleware/request-handler/request-event.ts | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 .changeset/moaning-master-chief.md diff --git a/.changeset/moaning-master-chief.md b/.changeset/moaning-master-chief.md new file mode 100644 index 00000000000..962242ed53b --- /dev/null +++ b/.changeset/moaning-master-chief.md @@ -0,0 +1,5 @@ +--- +'@builder.io/qwik-city': patch +--- + +fix: Redirect, error, and fail request events no longer forcefully delete user-defined Cache-Control HTTP header value. diff --git a/packages/qwik-city/src/middleware/request-handler/request-event.ts b/packages/qwik-city/src/middleware/request-handler/request-event.ts index 506387b5530..fb1b184b408 100644 --- a/packages/qwik-city/src/middleware/request-handler/request-event.ts +++ b/packages/qwik-city/src/middleware/request-handler/request-event.ts @@ -194,7 +194,6 @@ export function createRequestEvent( error: (statusCode: number, message: string) => { status = statusCode; - headers.delete('Cache-Control'); return new ErrorResponse(statusCode, message); }, @@ -208,10 +207,6 @@ export function createRequestEvent( } headers.set('Location', fixedURL); } - headers.delete('Cache-Control'); - if (statusCode > 301) { - headers.set('Cache-Control', 'no-store'); - } exit(); return new RedirectMessage(); }, @@ -223,7 +218,6 @@ export function createRequestEvent( fail: >(statusCode: number, data: T): FailReturn => { check(); status = statusCode; - headers.delete('Cache-Control'); return { failed: true, ...data,