Skip to content

Commit b7ba41a

Browse files
theandrew168elliott-with-the-longest-name-on-github
authored andcommitted
fix: don't send "Vary: Accept-Encoding" header when precompress=false (sveltejs#15182)
* Disable sirv compression checks when precompress=false * Add changeset * Update .changeset/sweet-spoons-study.md --------- Co-authored-by: Elliott Johnson <hello@ell.iott.dev>
1 parent 2a5348e commit b7ba41a

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

.changeset/sweet-spoons-study.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/adapter-node': patch
3+
---
4+
5+
fix: disable gzip and brotli when precompress=false

packages/adapter-node/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import './ambient.js';
33

44
declare global {
55
const ENV_PREFIX: string;
6+
const PRECOMPRESS: boolean;
67
}
78

89
interface AdapterOptions {

packages/adapter-node/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ export default function (opts = {}) {
104104
MANIFEST: './server/manifest.js',
105105
SERVER: './server/index.js',
106106
SHIMS: './shims.js',
107-
ENV_PREFIX: JSON.stringify(envPrefix)
107+
ENV_PREFIX: JSON.stringify(envPrefix),
108+
PRECOMPRESS: JSON.stringify(precompress)
108109
}
109110
});
110111

packages/adapter-node/src/handler.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { env } from 'ENV';
1212
import { parse_as_bytes } from '../utils.js';
1313

1414
/* global ENV_PREFIX */
15+
/* global PRECOMPRESS */
1516

1617
const server = new Server(manifest);
1718

@@ -47,8 +48,8 @@ function serve(path, client = false) {
4748
return fs.existsSync(path)
4849
? sirv(path, {
4950
etag: true,
50-
gzip: true,
51-
brotli: true,
51+
gzip: PRECOMPRESS,
52+
brotli: PRECOMPRESS,
5253
setHeaders: client
5354
? (res, pathname) => {
5455
// only apply to build directory, not e.g. version.json

0 commit comments

Comments
 (0)