Skip to content

Similar functionality's to Ocelot's "DownstreamHeaderTransform" #1410

Answered by Kahbazi
neptun09 asked this question in Q&A
Discussion options

You must be logged in to vote

There's no built-in configuration to replace request headers value but you can add your own transform. Something like this :

builder.Services
    .AddReverseProxy()
    .AddTransforms(transforms =>
    {
        // transforms.Cluster.Metadata 
        // get values from cluster metadata

        transforms.AddRequestTransform(context =>
        {
            if (context.ProxyRequest.Headers.TryGetValues("Test", out var value) && value.FirstOrDefault() == "http://www.bbc.co.uk/")
            {
                context.ProxyRequest.Headers.Remove("Test");
                context.ProxyRequest.Headers.Add("Test", "http://ocelot.com/");
            }
            return default;
        });
    });

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by neptun09
Comment options

You must be logged in to vote
1 reply
@Tratcher
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants