Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

"Host" header doesn't get passed by httpClient

I'm using the httpClient to make HTTP requests to a URL from within custom JavaScript code executing in a Shared-Flow that's used by API Proxy.

In the httpClient send() method I'm adding headers, but somehow the "Host" header does not get passed on to endpoint: (using it as in the example in docs)

var endpointRequest = new Request(endpointUrl, endpointOptions.method, endpointOptions.headers);
httpClient.send(endpointRequest, onComplete);

And endpointOptions.headers contains the Host- which I set explicitly:

headers["Host"] = context.getVariable('request.header.host');

When I print the endpointOptions.headers I see the expected host: 

endpointOptions headers: {.., "host":"34.95.96.135.nip.io", ..}

But in the endpoint I'm getting the host header as the endpointUrl Host. 

I saw a similar question regarding the Target- but in my case it's not the target of the Proxy, rather the target of the httpClient. This is blocking us, would like to hear how it can be relsoved, thanks

 

0 14 3,730
14 REPLIES 14