tmenier / Flurl

Fluent URL builder and testable HTTP client for .NET
https://flurl.dev
MIT License
4.23k stars 387 forks source link

Problem with reverse proxy (Yarp) #749

Closed alireza55 closed 1 year ago

alireza55 commented 1 year ago

Hello, At first thanks for wonderful Flurl! I have problem whit reverse proxy (Yarp) for fetching json data from api server, how to i can config flurl with reverse proxy .

for example this code return null from api gate way :

public class FlurlService
{
    private readonly ApiClientOptions _options;
    public FlurlService(IOptions<ApiClientOptions> options)
    {
        _options = options.Value;
    }

    public Url GetIdentityEndpoint(string endpointAdress)
    {
        return $"{_options.IdentityBaseApiAddress}{_options.IdentityEndpoint}"
               .AppendPathSegment(endpointAdress).ToUri();
    }
}

var data = ApiCall.GetIdentityEndpoint("/get-all-users").GetAsync().ReceiveJson<IList<UserResponse>>();

it's return a null data . In case of direct call api service (Not reverse proxy gate way) it's correct and return list data. Client app is blazor wasm. Regards,

tmenier commented 1 year ago

I'm not sure I follow. Have you tried doing the same with HttpClient? That's usually a good first step in figuring out how to do something atypical with Flurl, because it opens up any questions to a huge audience on Stack Overflow, and once you have the answer it should be simple to adapt to Flurl.

I generally prefer to keep programming questions out of Flurl issues, but if you can reply with a working sample demonstrating the solution with HttpClient, I can help you adapt it to Flurl.