question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use proxies?

See original GitHub issue

Hello 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
yovanoccommented, Sep 19, 2018

Any news on this? 😕

2reactions
cyberwombatcommented, Nov 20, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found