Skip to content
Discussion options

You must be logged in to vote

Refit does not manage the proxy itself - you set it on the HttpMessageHandler that backs the HttpClient, then hand that client to Refit.

Plain usage:

var handler = new HttpClientHandler
{
    Proxy = new WebProxy("http://your-proxy-ip:port"),
    UseProxy = true,
    // optional:
    // Credentials = new NetworkCredential("user", "pass")
};

var client = new HttpClient(handler)
{
    BaseAddress = new Uri("https://api.example.com")
};

var api = RestService.For<IMyApi>(client);

With IHttpClientFactory / DI:

services
    .AddRefitClient<IMyApi>()
    .ConfigureHttpClient(c => c.BaseAddress = new Uri("https://api.example.com"))
    .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHan…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by glennawatson
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