Skip to content

Commit fb0e772

Browse files
author
Paul Russell
committed
fix(content-negotiation) respect encoding file presence for Vary header
1 parent b2276b4 commit fb0e772

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/runtime/internal/static.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ export default eventHandler((event) => {
3636
withLeadingSlash(withoutTrailingSlash(parseURL(event.path).pathname))
3737
);
3838

39+
for (const encoding of Object.values(EncodingMap)) {
40+
if (getAsset(id + encoding)) {
41+
appendResponseHeader(event, "Vary", "Accept-Encoding");
42+
break;
43+
}
44+
}
45+
3946
let asset: PublicAsset | undefined;
4047

4148
const encodingHeader = String(
@@ -49,9 +56,6 @@ export default eventHandler((event) => {
4956
.sort(),
5057
"",
5158
];
52-
if (encodings.length > 1) {
53-
appendResponseHeader(event, "Vary", "Accept-Encoding");
54-
}
5559

5660
for (const encoding of encodings) {
5761
for (const _id of [id + encoding, joinURL(id, "index.html" + encoding)]) {

0 commit comments

Comments
 (0)