I am trying to set a Header - "Host" with a standard value hardcoded using Assign Message Policy. I see this particular header available on the final list of Request Headers sent to the backend (via the Apigee trace). But when I open the curl (using SHOW CURL option on the trace), I don't see this particular header listed. Even the backend system complained stating that the Host header was missing.
Additionally when I tried it with "Hosts" instead of "Host", things are working as expected.
So the question is - Is there any restriction in Apigee that we cannot send out Host header on the backend request ?
Solved! Go to Solution.
This is most likely due to how Apigee sets the host header from the TargetEndpoint configuration, either via a TargetServer, URL or templated URL.
You can use an Assign Message to set the special and currently undocumented `target.header.host` in the Target flow using:
<AssignMessage name="AM-set-target-host-us-west1">
<AssignVariable>
<Name>target.header.host</Name>
<Value>xapi-dev-apigeex-payg-kurt-us-west1.demo.net</Value>
</AssignVariable>
</AssignMessage>
Note that it must be sent in the Target flow.
Hi sameerudeen,
Welcome to the Community!
I don't believe the "show cURL" button will show a "host" header as cURL automatically sets the Host header based on the domain used in the Target's URL.
While I have not tried this recently, we can see in this related article, that it is possible to set the host header for the Target (not on a ServiceCallout) using the AssignMessage policy. The key is in setting the target.header.host variable. Ref: https://www.googlecloudcommunity.com/gc/Apigee/Is-there-a-way-to-set-the-host-header-on-a-service-ca...
Without overriding the host header, the Target should behave similarly to how cURL does and by default will set the host to the domain. Ideally, host header overrides should not be needed. However, we have seen customers using patterns that require this.
This is most likely due to how Apigee sets the host header from the TargetEndpoint configuration, either via a TargetServer, URL or templated URL.
You can use an Assign Message to set the special and currently undocumented `target.header.host` in the Target flow using:
<AssignMessage name="AM-set-target-host-us-west1">
<AssignVariable>
<Name>target.header.host</Name>
<Value>xapi-dev-apigeex-payg-kurt-us-west1.demo.net</Value>
</AssignVariable>
</AssignMessage>
Note that it must be sent in the Target flow.
it works fine. thank you
The `target.header.host` flow variable is documented as of today: https://cloud.google.com/apigee/docs/api-platform/reference/variables-reference#target