diff --git a/internal/rpc/rpc.go b/internal/rpc/rpc.go index f1af32ffa5..a2ebae853a 100644 --- a/internal/rpc/rpc.go +++ b/internal/rpc/rpc.go @@ -346,3 +346,26 @@ func logLevelForError(err error) log.Level { } return log.Warn } + +type hostOption struct { + host string +} + +func (h hostOption) WrapUnary(unaryFunc connect.UnaryFunc) connect.UnaryFunc { + return func(ctx context.Context, request connect.AnyRequest) (connect.AnyResponse, error) { + request.Header().Set("Host", h.host) + return unaryFunc(ctx, request) + } +} + +func (h hostOption) WrapStreamingClient(clientFunc connect.StreamingClientFunc) connect.StreamingClientFunc { + return clientFunc +} + +func (h hostOption) WrapStreamingHandler(handlerFunc connect.StreamingHandlerFunc) connect.StreamingHandlerFunc { + return handlerFunc +} + +func setHost(host string) connect.ClientOption { + return connect.WithInterceptors(hostOption{host: host}) +} \ No newline at end of file