Override host header

I am trying to override the host header of every request on a certain api definition.

“version_data”: {
“not_versioned”: true,
“versions”: {
“Default”: {
“name”: “Default”,

“global_headers”: {
“Host”: “somehost.com
}
}
}

The host header doesn’t change,
Am I missing something?

1 Like

Hi @aviv445,

Are you able to send the full API definition that you’re using for this example?

Also, how are you currently trying to achieve this, i.e middleware, url_rewrite or a combination of both as mentioned here by my colleagues: Overriding Host Header not working?


Valmir

I used a few methods,

  1. Adding to the api definition “global_headers”
  2. Creating a jsvm middleware and using request.SetHeaders[“Host”] = “Somehost.com

Had no luck with both…

I also noticed that “global_headers” aren’t modifying Host header but you can easily modify “X-Forwarded-Host” header which is a de-facto standard header for identifying the original host requested by the client.

It should work with most apps that support reverse proxies. Like keycloak etc.