From 03f59631d6fdb2f034ad65e49de5902c1dd2f5ff Mon Sep 17 00:00:00 2001 From: markthree <1801982702@qq.com> Date: Sun, 27 Aug 2023 05:07:45 +0800 Subject: [PATCH] fix(static): send immediate empty responses for 304 handling (#1639) --- src/runtime/static.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/runtime/static.ts b/src/runtime/static.ts index ee0e98ccce..bacb58f6db 100644 --- a/src/runtime/static.ts +++ b/src/runtime/static.ts @@ -6,7 +6,6 @@ import { setResponseHeader, setResponseStatus, removeResponseHeader, - send, } from "h3"; import { decodePath, @@ -76,8 +75,7 @@ export default eventHandler((event) => { const ifNotMatch = getRequestHeader(event, "if-none-match") === asset.etag; if (ifNotMatch) { setResponseStatus(event, 304, "Not Modified"); - send(event, ""); - return; + return ""; } const ifModifiedSinceH = getRequestHeader(event, "if-modified-since"); @@ -88,8 +86,7 @@ export default eventHandler((event) => { new Date(ifModifiedSinceH) >= mtimeDate ) { setResponseStatus(event, 304, "Not Modified"); - send(event, ""); - return; + return ""; } if (asset.type && !getResponseHeader(event, "Content-Type")) {