Using x-forwarded-host with the Delivery API

Is there any other header apart from ‘Host’ used to determine the root node to navigate from with the delivery API?

Currently for my multi hostname setup, my SSR container is having to override the host header to be able to get the correct information, front-end users are not affected as the url would change for them, but for the SSR container it only sees the internal back-end hostname for umbraco.

Ideally X-Forwarded-Host could be used over Host when provided & configured.

Hi @jam

Welcome to the forum!

There’s no mention of X-Forwarded-Host handling in the Umbraco source - from what AI tells me, that’s by design, as host resolution happens a layer down in ASP.NET Core. Umbraco (including the Delivery API’s request routing) just reads Request.Host, so the supported way to do what you’re after is the built-in ForwardedHeadersMiddleware, which rewrites Request.Host from X-Forwarded-Host before Umbraco sees the request:

builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
    options.ForwardedHeaders = ForwardedHeaders.XForwardedHost
        | ForwardedHeaders.XForwardedProto;
    // Only trust your SSR container/proxy, otherwise clients can spoof the host
    options.KnownProxies.Add(IPAddress.Parse("x.x.x.x"));
});

// Early in the pipeline, before Umbraco:
app.UseForwardedHeaders();

That gives you exactly the “use X-Forwarded-Host over Host when provided & configured” behaviour.

Justin