-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set http proxy while calling rest endpoint #7
Comments
Hi @anshul-kumar-agl, when you say "mention http proxy", do you mean some kind of header? If possible, please provide more details or analogy of what are you referring to. |
Like we mention a proxy url to go every request through in 'request' package as below. const request = require('request'); const options = { We have to route each request through a http proxy url like above. |
Sorry, I'm still confused. Probably you want to have some kind of base URL, so that your request would look like:
Is that right? If not, how would actual HTTP request look like if, let's say, you used something like Postman? |
Url would be complete url. Just that I want request to route through proxy url which internally routes to organisation network. The code I shared using package 'request' works because the url mentioned is reached by routing through http proxy mentioned in proxy property. Can we set options like above to HttpClient or HttpRequest of your package. |
Basically, our client is just a wrapper over XmlHttpRequest, which doesn't seem to have options like This is why I'm asking for an analogy. So, if you did raw HTTP request through Postman or Fiddler how would it look like? |
The request we do through postman has url and authorisation header. I don't see mentioning anything else. One difference is, since we have application on local machine which sets http proxy on localhost:9000, so application requests, web requests and presumably postman request route through http proxy and hence we get back data. |
Right, postman also cannot do that because it uses the same XmlHttpRequest. So, the only option, I think, is to have a setting that, depending on the environment, would switch between your localhost:9000 and production endpoint. |
@anshul-kumar-agl I think the best way to achieve what you are trying to do is to create a new custom HttpClient based on code from |
Hello, when calling a rest endpoint as below, I need to mention http proxy so that request goes through given proxy. How can we do same?
import { HttpClient, HttpRequest, HttpResponse, HttpMethod, HttpHeader } from "@paperbits/common/http";
response = await this.HttpClient.send(httpRequest);
The text was updated successfully, but these errors were encountered: