Skip to content

Commit 882ace2

Browse files
committed
fix(relay): make Code.gs header strip opt-in so Rust config is sole control
The comment in Code.gs and Config::strip_noise_response_headers claimed that setting strip_noise_response_headers = false in config.toml would pass all headers through "regardless of what Code.gs sends." This was wrong: with STRIP_NOISE_RESPONSE_HEADERS = true in Code.gs those headers are removed from the JSON before Rust receives it, so the Rust toggle cannot restore them. Fix: change Code.gs STRIP_NOISE_RESPONSE_HEADERS default from true to false. GAS-side stripping is now opt-in — operators who want the extra bandwidth reduction can flip it manually after deploying. With the default false, the Rust config.toml field is the single user-facing control that works correctly end-to-end: strip_noise_response_headers = false shows raw headers in the browser without requiring a simultaneous Code.gs redeploy. Update comments in Code.gs, config.rs, and domain_fronter.rs to document the relationship between the two layers accurately.
1 parent b91b83d commit 882ace2

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

assets/apps_script/Code.gs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,18 @@ const DIAGNOSTIC_MODE = false;
5252
// alt-svc, server-timing, etc. These add 400-700 bytes of JSON per response
5353
// for no benefit — the relay ignores them and the browser never reads them.
5454
//
55-
// STRIP_NOISE_RESPONSE_HEADERS controls whether _respHeaders() filters them
56-
// before returning. Hardcoded true here for GAS-side payload reduction.
5755
// The primary user toggle is `strip_noise_response_headers` in config.toml
58-
// on the Rust client side, which drops them even if Code.gs sends them.
56+
// on the Rust client side. That field controls what the browser sees and
57+
// works regardless of this constant.
5958
//
60-
// Set to false only if you need to see raw origin headers in GAS logs.
59+
// STRIP_NOISE_RESPONSE_HEADERS is a separate GAS-side optimization: when
60+
// true, headers are stripped before building the JSON payload, reducing the
61+
// data sent over the GAS -> Rust leg. Set to true only for extra bandwidth
62+
// savings. Leave false (the default) so the Rust config is the sole control
63+
// and `strip_noise_response_headers = false` in config.toml shows raw headers
64+
// without also requiring a Code.gs redeploy.
6165
// ---------------------------------------------------------------------------
62-
const STRIP_NOISE_RESPONSE_HEADERS = true;
66+
const STRIP_NOISE_RESPONSE_HEADERS = false;
6367

6468
const STRIP_RESPONSE_HEADERS = {
6569
"report-to": 1, "reporting-endpoints": 1,

src/config.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,12 @@ pub struct Config {
439439
/// `server-timing` are attached by modern CDNs (Cloudflare, AWS,
440440
/// Fastly) and add 400–700 bytes per response for no benefit through
441441
/// a MITM relay — the proxy ignores them and the browser never reads
442-
/// them. Default `true`. Set to `false` only to inspect raw origin
443-
/// headers for debugging.
442+
/// them. Default `true`. Set to `false` to pass all headers through.
443+
///
444+
/// Note: `Code.gs` has a separate `STRIP_NOISE_RESPONSE_HEADERS`
445+
/// constant (default `false`) that strips at the GAS side before the
446+
/// JSON reaches Rust. To see fully raw headers in the browser, both
447+
/// this field and the Code.gs constant must be `false`.
444448
#[serde(default = "default_strip_noise_response_headers")]
445449
pub strip_noise_response_headers: bool,
446450
}

src/domain_fronter.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,9 @@ pub struct DomainFronter {
415415
disable_padding: bool,
416416
/// Strip CDN noise headers (report-to, nel, alt-svc, etc.) from the
417417
/// relay response before forwarding to the browser. Default true.
418-
/// Mirrors `Config::strip_noise_response_headers`.
418+
/// Mirrors `Config::strip_noise_response_headers`. Independent of the
419+
/// GAS-side `STRIP_NOISE_RESPONSE_HEADERS` constant in Code.gs — both
420+
/// must be false to see fully raw headers.
419421
strip_noise_response_headers: bool,
420422
zstd_enabled: Arc<AtomicBool>,
421423
/// Per-instance auto-blacklist tuning. Mirrors `Config::auto_blacklist_*`

0 commit comments

Comments
 (0)