[Question] Using a Transform from code to modify proxy request headers in .net core 3.x application #1002
-
I am new to using YARP, It is so very developer friendly and makes to job a lot easier. Thanks to the community! I am trying to use YARP in a .net core 3.1 application and there is a need to transform the request response to add some custom headers conditionally, When I tried the approach of calling AddTranforms from Startup.ConfigureServices as shown below, services.AddReverseProxy()
.LoadFromConfig(_configuration.GetSection("ReverseProxy"))
.AddTransforms(
builderContext =>
{
builderContext.AddRequestTransform(
async transformContext =>
{
transformContext.ProxyRequest.Headers.Add("CustomHeader", "CustomValue");
});
}); I get a compilation error as below, I feel this is because the current c# language version is 8.0 as I am using .net core 3.1 framework and the ProxyRequest property is having and init accessor defined which is supported only from langversion 9.0. Is there a way to work around this problem without having to upgrade my framework version to .Net 5? As upgrading the framework version is currently not an option. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
See #837 |
Beta Was this translation helpful? Give feedback.
See #837