Modify Request and Response Headers
Change the headers of requests before they reach your service, and of responses before they reach the caller.
How it works
The gateway adds, replaces or removes headers on the request before it reaches the service, or on the response before it reaches the client. Typical uses: pass a tenant or a correlation ID to the service, remove internal headers from responses, strip identity headers a caller must not be able to forge.
Add versus set
set replaces any value sent by the caller; add appends to it. For a header the service trusts, use set.
Every parameter and its default: reference.
Use cases
To pass a fixed value to a service, to hide a header that reveals too much, or to add a security header to every response.
Prerequisites
- An API instance that is deployed and answers.
Procedure
- In API Manager, open the API instance.
- Add the setting HTTP request headers, HTTP response headers, or both.
- Fill Add Headers, Set Headers and Remove Headers.
- Deploy.
Parameters
| Field | What it is | Default |
|---|---|---|
| Add Headers | Headers added, even when one of the same name is already there. | — |
| Set Headers | Headers set: an existing value is replaced. | — |
| Remove Headers | Names of the headers removed. | — |
Verification
See the headers of a response
curl -sI https://orders.example.com/orders
Behavior and limits
- Add keeps an existing header and adds another; Set replaces it. Use Set when the value must be the only one.