Skip to content
Discussion options

You must be logged in to vote

ReadFromJsonAsync will consume the request body stream, so when YARP tries to proxy the request, there will be a mismatch between the Content-Length header and the content actually available.

I would suggest transforming the request body into the query before invoking the forwarder.

For this to work you will also have to change the request's method to GET and clear the Content-Length header as well.

app.MapReverseProxy(proxyPipeline =>
{
    proxyPipeline.Use(static async (context, next) =>
    {
        if (context.Request.Method == HttpMethods.Post)
        {
            var proxyFeature = context.GetReverseProxyFeature();
            if (proxyFeature?.Route.Config.RouteId == "route2")

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sreejith-ms
Comment options

Answer selected by sreejith-ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants