Hi demis,
my use case: proxy an api & append some header fields.
docs (https://docs.servicestack.net/proxy-feature):
// Customize the HTTP Request Headers that are sent to downstream server
Action<IHttpRequest, HttpWebRequest> ProxyRequestFilter
How are we supposed to e.g. add a header value?
As soon is i add this line, the proxy wont work anymore:
ProxyRequestFilter = (request, webRequest) => webRequest.Headers.Add("Some-Header", "xxx"),
the ss-api interestingly returns with a 200, but the request never hits my downstream server + there is no response.
request.Headers.Add() throws not implemented exception. my downstream is a simple requestbin.com to test.
Full code:
Plugins.Add(new ProxyFeature(
matchingRequests: req => req.PathInfo.StartsWith("/proxy-api"),
resolveUrl: req => $"https://XXXXXXX.x.pipedream.net" + req.RawUrl.Replace("/proxy-api", ""))
{
ProxyRequestFilter = (request, webRequest) => webRequest.Headers.Add("XXX", "YYY"),
});