I am trying to convert an Azure Function app from the worker model InProcess
to Isolated Process
. For this I have decided to use the aspnet-core-integration
, so my HttpTrigger
takes in Microsoft.AspNetCore.Http.HttpRequest req
as an argument.
req.host
is used to return a RedirectUrl
for another function/endpoint running on the same domain, let's say https://foobar.com/public/server-configuration
returns some json containing a RedirectUrl
for https://foobar.com/public/authenticated-server-configuration
.
Inside of the HttpTrigger
for https://foobar.com/public/server-configuration
I expected the req.host
to be equal to foobar.com
, but in this case I receive localhost
, I get the feeling that it is somehow being rewritten locally.
This is just speculation but since my app is now being hosted in a different process, the host process for Azure functions will receive the request, startup a new process to handle the request, rewrite the request and sent it to the new process using localhost
. Does anyone know what is going on? I was able to obtain the req.host
using InProcess w/ the same infrastructure w.r.t proxies etc.
EDIT: maybe something like X-Forwarded-Host
header would contain my real host?
Seems that X-Forwarded-Host
is indeed a way to get the original req.host
I'm changing req.host
to req.Headers["X-Forwarded-Host"]
but maybe w/ some slight modifications for making it more robust.