I have an angular application running on heroku, that needs to access external API that is accesible only through IP configured in QuotaGuard.
constructor(private http: HttpClient){}
proxy = new URL("http://username:password@ip:port");
private proxySend(){
this.http.get("http://targetlocation/").subscribe((data:any) => {
console.log("target-proxy:", data);
});
}
I saw here: Static IP Address with Heroku (not Proximo) that setting up a proxy in ruby is just a configuration for httpClient, how does it work in Angular? I'd like to use proxy in mine requests, as my heroku app has a dynamic IP and only way to use static is QuotaGuard.
let options = {
hostname: proxy.hostname,
port: proxy.port || 80,
path: target.href,
headers:
{
"Proxy-Authorization": "Basic " + key,
"Host" : target.hostname
}
}
this.http.request("GET", target.href, options).subscribe((data:any) => {
console.log("target:", data);
});
}
I've tried this as well, however this and previous results in CORS error. Also in second approach I'm getting information about the fact that I shouldn't set headers Proxy-authorization and Host.
I've tried also to replicate this requests in postman with just none headers and I've been returned with error message about mine IP address being wrong, not just CORS like previously.
Thanks for help :)