From 40315e72ffe33f3886bf28331d6fdbc47cfe083b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Charles?= Date: Mon, 25 Nov 2024 11:51:00 +0100 Subject: [PATCH] fix: remove restriction on nodeReq in compressMiddleware --- packages/vike-node/src/runtime/vike-handler.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/vike-node/src/runtime/vike-handler.ts b/packages/vike-node/src/runtime/vike-handler.ts index 1bd56ff..b8a8baa 100644 --- a/packages/vike-node/src/runtime/vike-handler.ts +++ b/packages/vike-node/src/runtime/vike-handler.ts @@ -34,13 +34,12 @@ async function renderPage({ } export const compressMiddleware = ((options?) => async (request, _context, runtime: any) => { - const nodeReq: IncomingMessage | undefined = runtime.req const compressionType = options?.compress ?? !isVercel() const compressMiddlewareInternal = compressMiddlewareFactory()(request) return async (response) => { - if (!globalStore.isDev && nodeReq) { - const isAsset = nodeReq.url?.startsWith('/assets/') + if (!globalStore.isDev) { + const isAsset = new URL(request.url).pathname.startsWith('/assets/') const shouldCompressResponse = compressionType === true || (compressionType === 'static' && isAsset) if (shouldCompressResponse) { return compressMiddlewareInternal(response)