How to use proxies?
See original GitHub issueHello I tried to use proxies but all i tried was unsuccessful, if someone can help me.
With the https module with node all works well but axios doesn’t work (it returns my ip and not proxy one)
import HttpsProxyAgent from "@/utils/proxy/https";
import axios, { AxiosRequestConfig } from "axios";
import * as https from "https";
const proxy = "http://186.193.186.3:20183";
const agent = new HttpsProxyAgent(proxy);
const opts: https.RequestOptions = {
agent,
host: "ip.jsontest.com",
method: "POST",
path: "/",
port: 80,
timeout: 10000
};
const post_req = https.request(opts, res => {
res.setEncoding("utf8");
res.on("data", chunk => {
console.log("Response: " + chunk);
});
});
// post_req.write("name=john");
post_req.end();
const config: AxiosRequestConfig = {
baseURL: "http://ip.jsontest.com:80",
httpsAgent: agent,
proxy: false
};
const myaxios = axios.create(config);
myaxios.get("/").then(res => console.log("xxx res", res.data));
Response:
xxx res {ip: "MY IP HERE"}
Response: {"ip": "186.193.186.3"}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to Set Up a Proxy Server on Your PC, Mac, or Web Browser
Click Start and select Settings (the gear icon) from the Start menu. · Choose Network & Internet. · Click Proxy in the left...
Read more >What is a Proxy Server? How does it work? - Fortinet
It works by intercepting requests from the user at the network edge of the web server. It then sends the requests to and...
Read more >Connecting to a proxy server - IBM
Open Edge. · Click Settings and more > Advanced > Open proxy settings. · Under Manual proxy setup, select Use a proxy server....
Read more >Proxy Server - What They Are & How to Use
Forward proxies are the most common type of proxy server. The work by taking a request and passing it through from an isolated,...
Read more >What is a Proxy Server and How Does it Work? - Varonis
If you're using a proxy server, internet traffic flows through the proxy server on its way to the address you requested. The request...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any news on this? 😕
I’ve had a similar issue and can confirm that this method https://github.com/axios/axios/issues/847#issue-222517050 works. I am not able to use an https proxy but have it working with http. I am using hookbin.com for testing and it correctly shows my proxy URL.