Is there a recommended way of defining a proxy for flurl clients based on the URL (or base URL)? I could not find anything in the documentation and discussions of the topic I did find (such as Setting a per-request proxy (or rotating proxies) with .NET Flurl/HttpClient) focuses on somewhat more complicated cases and How can I use proxies for web requests in Flurl? seems to set up the setting that would affect all calls (unless I misunderstood it).
In our scenario, an app calls different endpoints (other apps). Some of these endpoints can only be reached via a proxy server, some can be reached directly. Also, in some environments (DEV vs. PREPROD vs PROD), the same endpoints may need or not need a proxy, so the configuration could be similar to:
DEV
- https://x.com/endpoint1 (no proxy)
- https://y.com/endpoint2 (no proxy)
- https://z.com/endpoint3 (no proxy)
PREPROD
- https://x.com/endpoint1 (proxy A)
- https://y.com/endpoint2 (proxy B)
- https://z.com/endpoint3 (no proxy)
PROD
- https://x.com/endpoint1 (proxy A)
- https://y.com/endpoint2 (proxy B)
- https://z.com/endpoint3 (proxy A)
In this scenario, I assume that we need three HTTP clients (X, Y, and Z). What would be the right way to configure proxy settings for these clients?