googleapis / google-api-nodejs-client

Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
https://googleapis.dev/nodejs/googleapis/latest/
Apache License 2.0
11.36k stars 1.92k forks source link

Global and local proxy settings #1943

Open glebmlk opened 4 years ago

glebmlk commented 4 years ago

Hello!

The documentation here https://github.com/googleapis/google-api-nodejs-client#using-a-proxy says that I can override global proxy settings (via HTTPS_PROXY) somehow for a particular request. Please note how it is possible. I couldn't find no proxy property for googleapis requests, nor its API clients.

e.g. in my case I want every googleapi request to pass through a proxy, but I don't want to use global proxy (environment variable). Is this possible?

1899

JustinBeckwith commented 4 years ago

Greetings! I'm curious - what's your use case for only wanting the proxy on some requests, but not others? Generally it's an all or nothing deal :)

glebmlk commented 4 years ago

Hi @JustinBeckwith, we have a bunch of other microservices that our backend is communicating with, some of which are in the same network, some are external. We don't want to pass all requests through a proxy

glebmlk commented 4 years ago

So, is there a way to override proxy settings or it is not implemented?

bcoe commented 4 years ago

@glebmlk unfortunately, I think your best bet at this point would be to introduce an additional proxy, which redirects requests for internal services to a service that makes the request without a proxy set, and redirects requests for Google APIs with a proxy variable set ... so split it into two tiny little services.

In the future we could look in to accepting a parameter here.

glebmlk commented 4 years ago

OK, thank you

wong2 commented 4 years ago

I also need per request proxy

wong2 commented 4 years ago

In China, we need proxy to access Google APIs, but not other network requests. So I can't set a global HTTP_PROXY.

jjhesk commented 4 years ago

I also need per request proxy