When using C#, I am able to:
public static IWebProxy GetWebProxy() {
var proxyUrl = Environment.GetEnvironmentVariable("HTTPS_PROXY");
if (!string.IsNullOrEmpty(proxyUrl)) {
var proxy = new WebProxy {
Address = new Uri(proxyUrl),
BypassProxyOnLocal = false,
UseDefaultCredentials = false,
};
return proxy;
}
return null;
}
and then create a client like :
var httpClientHandler = new HttpClientHandler { Proxy = proxy, };
var client new HttpClient(handler: httpClientHandler, disposeHandler: true);
Now, I would like to achieve the same functionality using Angular and typescript. For instance, when using request
, I attempted:
const options = {
method: 'POST',
url: endPoint,
proxy: 'xxxxx'
headers: {
contentHeader,
},
body: JSON.stringify({
classId: class_id,
roomId: room_id,
}),
};
request(options, function (_error: Error, _response: any, data: string) {
}
however, unfortunately, it did not work as expected.