@@ -160,12 +160,42 @@ fn main() {
160160
161161/// Handles a request through the `EdgeZero` router path.
162162fn edgezero_main ( mut req : FastlyRequest , config_store : ConfigStoreHandle ) {
163+ // Short-circuit the JA4 debug probe before app construction, mirroring
164+ // legacy_main. Must run here because TLS/JA4 accessors are only available
165+ // on FastlyRequest before conversion to edgezero types.
166+ if req. get_method ( ) == FastlyMethod :: GET && req. get_path ( ) == "/_ts/debug/ja4" {
167+ match get_settings ( ) {
168+ Ok ( settings) if settings. debug . ja4_endpoint_enabled => {
169+ build_ja4_debug_response ( & req) . send_to_client ( ) ;
170+ }
171+ Ok ( _) => {
172+ FastlyResponse :: from_status ( fastly:: http:: StatusCode :: NOT_FOUND ) . send_to_client ( ) ;
173+ }
174+ Err ( e) => {
175+ log:: warn!( "EdgeZero JA4 endpoint: failed to load settings: {e:?}" ) ;
176+ FastlyResponse :: from_status ( fastly:: http:: StatusCode :: INTERNAL_SERVER_ERROR )
177+ . with_body_text_plain ( "Internal Server Error" )
178+ . send_to_client ( ) ;
179+ }
180+ }
181+ return ;
182+ }
183+
163184 let app = TrustedServerApp :: build_app ( ) ;
164185
165186 // Strip client-spoofable forwarded headers before handing off to the
166187 // EdgeZero dispatcher, mirroring the sanitization done in legacy_main.
167188 compat:: sanitize_fastly_forwarded_headers ( & mut req) ;
168189
190+ // Re-inject a trusted TLS scheme signal after sanitization has stripped any
191+ // client-sent fastly-ssl header. Setting it from Fastly's native TLS
192+ // metadata here is authoritative. detect_request_scheme in http_util
193+ // checks this header so scheme-sensitive logic (publisher URL rewriting,
194+ // etc.) produces https URLs on HTTPS traffic, matching legacy path parity.
195+ if req. get_tls_protocol ( ) . is_some ( ) || req. get_tls_cipher_openssl_name ( ) . is_some ( ) {
196+ req. set_header ( "fastly-ssl" , "1" ) ;
197+ }
198+
169199 // Capture client IP before the request is consumed by dispatch.
170200 let client_ip = req. get_client_ip_addr ( ) ;
171201
0 commit comments