@@ -16,7 +16,6 @@ import (
1616 "google.golang.org/grpc/codes"
1717 "google.golang.org/grpc/status"
1818
19- "github.com/e2b-dev/infra/packages/shared/pkg/env"
2019 "github.com/e2b-dev/infra/packages/shared/pkg/featureflags"
2120 proxygrpc "github.com/e2b-dev/infra/packages/shared/pkg/grpc/proxy"
2221 "github.com/e2b-dev/infra/packages/shared/pkg/logger"
@@ -63,6 +62,17 @@ func normalizeNodeIP(nodeIP string) (string, error) {
6362 return nodeIP , nil
6463}
6564
65+ func legacySandboxHostForEnvdRequest (host string , sandboxID string , port uint64 ) * string {
66+ hostname := strings .Split (host , ":" )[0 ]
67+ domain , ok := strings .CutPrefix (hostname , "envd." )
68+ if ! ok || domain == "" {
69+ return nil
70+ }
71+
72+ legacyHost := fmt .Sprintf ("%d-%s.%s" , port , sandboxID , domain )
73+ return & legacyHost
74+ }
75+
6676func catalogResolution (ctx context.Context , sandboxId string , sandboxPort uint64 , trafficAccessToken string , envdAccessToken string , c catalog.SandboxesCatalog , pausedChecker PausedSandboxResumer , featureFlags * featureflags.Client ) (string , error ) {
6777 s , err := c .GetSandbox (ctx , sandboxId )
6878 if err != nil {
@@ -133,7 +143,7 @@ func handlePausedSandbox(
133143}
134144
135145func NewClientProxy (meterProvider metric.MeterProvider , serviceName string , port uint16 , catalog catalog.SandboxesCatalog , pausedSandboxResumer PausedSandboxResumer , featureFlagsClient * featureflags.Client ) (* reverseproxy.Proxy , error ) {
136- getTargetFromRequest := reverseproxy .GetTargetFromRequest (env . IsLocal () )
146+ getTargetFromRequest := reverseproxy .GetTargetFromRequest (true )
137147 proxy := reverseproxy .New (
138148 port ,
139149 // Retries that are needed to handle port forwarding delays in sandbox envd are handled by the orchestrator proxy
@@ -198,6 +208,11 @@ func NewClientProxy(meterProvider metric.MeterProvider, serviceName string, port
198208 SandboxPort : port ,
199209 ConnectionKey : pool .ClientProxyConnectionKey ,
200210 Url : url ,
211+ MaskRequestHost : legacySandboxHostForEnvdRequest (
212+ r .Host ,
213+ sandboxId ,
214+ port ,
215+ ),
201216 }, nil
202217 },
203218 nil ,
0 commit comments