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.

Sent requests via HTTP proxy

See original GitHub issue

It would be nice to be able to use the google-api-nodejs-client via a HTTP proxy. Request appears to support proxy configuration.

Possibly via the withOpts:

discover('youtube', 'v3').withOpts({ proxy: 'http://mylocalproxy.com' });

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
aguegucommented, Oct 11, 2014

As checking request doc,

add this line before google.options({ proxy: ‘http://127.0.0.1:7777’ }); helps:

process.env.HTTPS_PROXY = ‘http://127.0.0.1:7777’;

https://github.com/mikeal/request#controlling-proxy-behaviour-using-environment-variables

1reaction
mirismailicommented, Sep 3, 2020

I tried google.options({ proxy: 'http://SOMETHING_WRONG' }). It works regularly! So it shouldn’t be the correct setting.

I found the below option works as expected:

const HttpsProxyAgent = require('https-proxy-agent')
const {google} = require('googleapis')
google.options({
	agent: new HttpsProxyAgent('http://127.0.0.1:8580')
})

This crashes on invalid proxies and works on valid proxies, as expected.


Ref: https://github.com/googleapis/google-api-nodejs-client#request-options says:

For more fine-tuned control over how your API calls are made, we provide you with the ability to specify additional options that can be applied directly to the ‘gaxios’ object used in this library to make network calls to the API.

And gaxios introduces itself:

An HTTP request client that provides an axios like interface over top of node-fetch

And node-fetch uses http-agent:

https://github.com/node-fetch/node-fetch#custom-agent

Read more comments on GitHub >

github_iconTop Results From Across the Web

6.5. Tricky Things About Proxy Requests - HTTP - O'Reilly
Tricky Things About Proxy Requests This section explains some of the tricky and much misunderstood aspects of proxy server requests, including: How the...
Read more >
How to Use a Proxy with Python Requests? - ScrapingBee
To use a proxy in Python, first import the requests package. Next create a proxies dictionary that defines the HTTP and HTTPS connections....
Read more >
how does http proxy work? - Stack Overflow
The SERVER will only see the PROXY as connection and answer to the PROXY just like to a CLIENT. The PROXY receives the...
Read more >
Proxy servers and tunneling - HTTP - MDN Web Docs
Proxies can make requests appear as if they originated from the proxy's IP address. This can be useful if a proxy is used...
Read more >
Sending HTTP Requests through Proxy Server using Python
This video explains how to send HTTP requests through proxy server using requests library in Python.
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