diff --git a/connect/handler.go b/connect/handler.go index a40550c0..2c4a7cf1 100644 --- a/connect/handler.go +++ b/connect/handler.go @@ -34,7 +34,7 @@ func Connect(ctx context.Context, opts Opts, invoker FunctionInvoker, logger *sl notifyConnectDoneChan: make(chan connectReport), notifyConnectedChan: make(chan struct{}), initiateConnectionChan: make(chan struct{}), - apiClient: newWorkerApiClient(opts.APIBaseUrl), + apiClient: newWorkerApiClient(opts.APIBaseUrl, opts.Env), } wp := NewWorkerPool(ctx, opts.WorkerConcurrency, ch.processExecutorRequest) diff --git a/connect/workerapi.go b/connect/workerapi.go index 01d90676..e22e27ec 100644 --- a/connect/workerapi.go +++ b/connect/workerapi.go @@ -12,12 +12,14 @@ import ( type workerApiClient struct { client http.Client + env *string apiBaseUrl string } -func newWorkerApiClient(apiBaseUrl string) *workerApiClient { +func newWorkerApiClient(apiBaseUrl string, env *string) *workerApiClient { return &workerApiClient{ apiBaseUrl: apiBaseUrl, + env: env, } } @@ -35,6 +37,10 @@ func (a *workerApiClient) start(ctx context.Context, hashedSigningKey []byte, re httpReq.Header.Set("Content-Type", "application/protobuf") httpReq.Header.Set("Authorization", fmt.Sprintf("Bearer %s", string(hashedSigningKey))) + if a.env != nil { + httpReq.Header.Add("X-Inngest-Env", *a.env) + } + httpRes, err := a.client.Do(httpReq) if err != nil { return nil, fmt.Errorf("could not send start request: %w", err)