From 89a9e79f797816fd466f2d7d6ee74c0f2fa1dd75 Mon Sep 17 00:00:00 2001 From: Aram Grigoryan <132480+aram356@users.noreply.github.com> Date: Wed, 18 Feb 2026 13:11:46 -0800 Subject: [PATCH 1/2] Add X-TS-Version and X-TS-Env response headers for staging identification Expose FASTLY_SERVICE_VERSION as X-TS-Version on every response, and set X-TS-Env: staging when FASTLY_IS_STAGING=1. This makes it trivial to tell staging from production via curl or browser DevTools. Adds constants for both the Fastly env vars and the header names. Closes #325 Co-Authored-By: Claude Opus 4.6 --- crates/common/src/constants.rs | 8 ++++++++ crates/fastly/src/main.rs | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs index 4ccb77f9..ea51df86 100644 --- a/crates/common/src/constants.rs +++ b/crates/common/src/constants.rs @@ -19,6 +19,14 @@ pub const HEADER_X_REQUEST_ID: HeaderName = HeaderName::from_static("x-request-i pub const HEADER_X_COMPRESS_HINT: HeaderName = HeaderName::from_static("x-compress-hint"); pub const HEADER_X_DEBUG_FASTLY_POP: HeaderName = HeaderName::from_static("x-debug-fastly-pop"); +// Staging / version identification headers +pub const HEADER_X_TS_VERSION: HeaderName = HeaderName::from_static("x-ts-version"); +pub const HEADER_X_TS_ENV: HeaderName = HeaderName::from_static("x-ts-env"); + +// Fastly environment variables +pub const ENV_FASTLY_SERVICE_VERSION: &str = "FASTLY_SERVICE_VERSION"; +pub const ENV_FASTLY_IS_STAGING: &str = "FASTLY_IS_STAGING"; + // Common standard header names used across modules pub const HEADER_USER_AGENT: HeaderName = HeaderName::from_static("user-agent"); pub const HEADER_ACCEPT: HeaderName = HeaderName::from_static("accept"); diff --git a/crates/fastly/src/main.rs b/crates/fastly/src/main.rs index 0112bd99..e5182bf6 100644 --- a/crates/fastly/src/main.rs +++ b/crates/fastly/src/main.rs @@ -6,6 +6,9 @@ use log_fastly::Logger; use trusted_server_common::auction::endpoints::handle_auction; use trusted_server_common::auction::{build_orchestrator, AuctionOrchestrator}; use trusted_server_common::auth::enforce_basic_auth; +use trusted_server_common::constants::{ + ENV_FASTLY_IS_STAGING, ENV_FASTLY_SERVICE_VERSION, HEADER_X_TS_ENV, HEADER_X_TS_VERSION, +}; use trusted_server_common::error::TrustedServerError; use trusted_server_common::integrations::IntegrationRegistry; use trusted_server_common::proxy::{ @@ -63,7 +66,7 @@ async fn route_request( ) -> Result { log::info!( "FASTLY_SERVICE_VERSION: {}", - ::std::env::var("FASTLY_SERVICE_VERSION").unwrap_or_else(|_| String::new()) + ::std::env::var(ENV_FASTLY_SERVICE_VERSION).unwrap_or_else(|_| String::new()) ); if let Some(response) = enforce_basic_auth(settings, &req) { @@ -132,6 +135,13 @@ async fn route_request( // Convert any errors to HTTP error responses let mut response = result.unwrap_or_else(|e| to_error_response(&e)); + if let Ok(v) = ::std::env::var(ENV_FASTLY_SERVICE_VERSION) { + response.set_header(HEADER_X_TS_VERSION, v); + } + if ::std::env::var(ENV_FASTLY_IS_STAGING).as_deref() == Ok("1") { + response.set_header(HEADER_X_TS_ENV, "staging"); + } + for (key, value) in &settings.response_headers { response.set_header(key, value); } From 1a78e61339f8d18aad6bfa93b6e5a3224c0919cd Mon Sep 17 00:00:00 2001 From: Aram Grigoryan <132480+aram356@users.noreply.github.com> Date: Wed, 18 Feb 2026 13:43:57 -0800 Subject: [PATCH 2/2] Remove unnessary logging of Fastly service version in main request handler --- crates/fastly/src/main.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crates/fastly/src/main.rs b/crates/fastly/src/main.rs index e5182bf6..33b58f37 100644 --- a/crates/fastly/src/main.rs +++ b/crates/fastly/src/main.rs @@ -64,11 +64,6 @@ async fn route_request( integration_registry: &IntegrationRegistry, req: Request, ) -> Result { - log::info!( - "FASTLY_SERVICE_VERSION: {}", - ::std::env::var(ENV_FASTLY_SERVICE_VERSION).unwrap_or_else(|_| String::new()) - ); - if let Some(response) = enforce_basic_auth(settings, &req) { return Ok(response); }