@@ -39,8 +39,6 @@ const (
3939 ContextKeyOpTxProxyAuth = "op_txproxy_auth"
4040 ContextKeyInteropValidationStrategy = "interop_validation_strategy"
4141 ContextKeyHeadersToForward = "headers_to_forward"
42- ContextKeyRawQuery = "raw_query"
43- ContextKeyPath = "path"
4442 DefaultOpTxProxyAuthHeader = "X-Optimism-Signature"
4543 FlashbotsAuthHeader = "X-Flashbots-Signature"
4644 DefaultMaxBatchRPCCallsLimit = 100
@@ -782,10 +780,6 @@ func (s *Server) populateContext(w http.ResponseWriter, r *http.Request) context
782780
783781 ctx := context .WithValue (r .Context (), ContextKeyXForwardedFor , xff ) // nolint:staticcheck
784782
785- // Store query parameters and path for forwarding to backend
786- ctx = context .WithValue (ctx , ContextKeyRawQuery , r .URL .RawQuery ) // nolint:staticcheck
787- ctx = context .WithValue (ctx , ContextKeyPath , r .URL .Path ) // nolint:staticcheck
788-
789783 opTxProxyAuth := r .Header .Get (DefaultOpTxProxyAuthHeader )
790784 if opTxProxyAuth != "" {
791785 ctx = context .WithValue (ctx , ContextKeyOpTxProxyAuth , opTxProxyAuth ) // nolint:staticcheck
@@ -802,19 +796,26 @@ func (s *Server) populateContext(w http.ResponseWriter, r *http.Request) context
802796 ctx = context .WithValue (ctx , ContextKeyAuth , s .authenticatedPaths [authorization ]) // nolint:staticcheck
803797 }
804798
805- if len (s .allowedDynamicHeaders ) > 0 {
806- filteredHeaderValues := make (map [string ][]string )
807- for _ , h := range s .allowedDynamicHeaders {
808- values := r .Header .Values (h )
809- if len (values ) > 0 {
810- filteredHeaderValues [h ] = values
811- }
812- }
813- if len (filteredHeaderValues ) > 0 {
814- log .Info ("proxying dynamic headers" )
815- ctx = context .WithValue (ctx , ContextKeyHeadersToForward , filteredHeaderValues ) // nolint:staticcheck
799+ // Collect all headers to forward to backends
800+ headersToForward := make (map [string ][]string )
801+
802+ // Always include URL context as synthetic headers
803+ if r .URL .Path != "" && r .URL .Path != "/" {
804+ headersToForward ["X-Original-Path" ] = []string {r .URL .Path }
805+ }
806+ if r .URL .RawQuery != "" {
807+ headersToForward ["X-Original-Query" ] = []string {r .URL .RawQuery }
808+ }
809+
810+ // Conditionally include allowed request headers
811+ for _ , h := range s .allowedDynamicHeaders {
812+ if values := r .Header .Values (h ); len (values ) > 0 {
813+ headersToForward [h ] = values
816814 }
815+ }
817816
817+ if len (headersToForward ) > 0 {
818+ ctx = context .WithValue (ctx , ContextKeyHeadersToForward , headersToForward ) // nolint:staticcheck
818819 }
819820
820821 return context .WithValue (
0 commit comments