firebase-tools: Unable to deploy behind a proxy

Hi,

I’m following the firebase web tutorial (https://codelabs.developers.google.com/codelabs/firebase-web/). Everything works fine for the 8 first steps, but in step 9 I have a problem : the command firebase deploy hangs indefinitely. I have this behavior while being behind a proxy (http_proxy and https_proxy are set in the env).

Is there a way to deploy behind a proxy ? This seems related to issue #36

Yann


Here is the output of firebase deploy --debug

----------------------------------------------------------------------
Command:      node /Users/ymainier/.nvm/versions/node/v0.12.1/bin/firebase deploy --debug
CLI Version:  3.0.0
Platform:     darwin
Node Version: v0.12.1
Time:         Wed May 25 2016 16:46:59 GMT+0200 (CEST)
----------------------------------------------------------------------

> command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]
>>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/friendlychat-dd6a6 
<<< HTTP RESPONSE 200 server=nginx, date=Wed, 25 May 2016 14:47:57 GMT, content-type=application/json; charset=utf-8, content-length=124, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
>>> HTTP REQUEST GET https://admin.firebase.com/v1/database/friendlychat-dd6a6/tokens 
<<< HTTP RESPONSE 200 server=nginx, date=Wed, 25 May 2016 14:47:57 GMT, content-type=application/json; charset=utf-8, content-length=433, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 53
  • Comments: 166 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Hope this will help you: firebase-tools@7.15.1 it works on both win and mac with ssr

  1. find your proxy address WeChatd29e8b5b594f8cff963da7441b84fbc9

  2. open “request.js” file in your firebase tools folder. for me, the path is /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js use “npm root -g” to find your global npm path

  3. find the code below, about line 276

  if (!self.hasOwnProperty('proxy')) {
    self.proxy = getProxyFromURI(self.uri)
  }

change it to

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = "http://127.0.0.1:1087";  // this is your proxy address
  1. use firebase login --no-localhost

Firebase devs please solve this issue, it a serious dev delay up to date.

It still happens and keeps bothering me… Maybe I will give up firebase because I am in China…

One year and still no fix?

Come on, evil googol…

This is a known issue. We’d like to figure out a workaround, but it may take some time. I’ll leave the issue open to track.

##############

SOLUTION

#############

  1. run ‘firebase login --interactive’ so log in @gmail account.

This Works!!!

Why is it not solved until now?

export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;export NO_PROXY=localhost,127.0.0.1

@chen86860 No, you don’t modify the source code now, just export proxy in your environment:

$ export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;

It’s 2018, still no fix to it, look likes they don’t maintain it.

Hope this will help you: firebase-tools@7.15.1 it works on both win and mac with ssr

  1. find your proxy address
WeChatd29e8b5b594f8cff963da7441b84fbc9
  1. open “request.js” file in your firebase tools folder. for me, the path is /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js use “npm root -g” to find your global npm path
  2. find the code below, about line 276
  if (!self.hasOwnProperty('proxy')) {
    self.proxy = getProxyFromURI(self.uri)
  }

change it to

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = "http://127.0.0.1:1087";  // this is your proxy address
  1. use firebase login --no-localhost IT WORKED

Update. Just made login working.

  1. run Git Bash or any Linux-like command line tool
  2. execute these commands, substitute your proxy instead

export HTTP_PROXY=“http://proxy.XXXXXXXX.com:80/” export HTTPS_PROXY=“http://proxy.XXXXXXXX.com:80/

  1. after this I was able to login using

firebase login --interactive

  1. useful links

https://github.com/firebase/firebase-tools/issues/36#issuecomment-66696746 https://www.npmjs.com/package/request#controlling-proxy-behaviour-using-environment-variables

confirmed working solution:

  1. set env var http_proxy since is still needed (and being respected) by request
  2. hack faye-websocket/lib/faye/websocket/client.js:
...
var Client = function(_url, protocols, options) {
  options = options || {};

  options.proxy = {
    origin:  'http://localhost:1087',
  }
...
  1. set NODE_TLS_REJECT_UNAUTHORIZED=0
  2. dont trust issue labels such as p2

Same problem…

Same problem

Same issue here!!!

“Error: Authentication Error: Your credentials are no longer valid. Please run firebase login --reauth For CI servers and headless environments, generate a new token with firebase login:ci”

when I “firebase login” ,there is the problem…I solved by “firebase login --no-localhost” for now. But "firebase init"and “firebase deploy” I can’t fix it. Always “Authentication Error”

in Powershell on Windows 10 powered by shadowsocks.

PS> $env:http_proxy = 'http://127.0.0.1:1080'
PS> $env:https_proxy = 'http://127.0.0.1:1080'
PS> $env:NO_PROXY = 'localhost,127.0.0.1'
PS> firebase login

We have made some additional updates in v4.1.2 that might fix firebase deploy proxy issues. Please give it a try and let me know if it’s not working!

It is unacceptable, after two years, this problem is still not fixed? wth?

waiting for official solution… this issue has CRITICAL PRIORITY

One solution could be, to move to another country 💃

It is always like this if you are an android developer who is living in China.

I just hope that Google Play will come back one day.

Looking at the code, the new version can get the proxy from the environment variable,

My situation here is that using localhost or 127.0.0.1 will fail. So use the IP:port of the proxy server in the LAN

Three ways to set environment variables

In CMD

set HTTPS_PROXY=http:// IP:port << don't use localhost or 127.0.0.1
set NODE_TLS_REJECT_UNAUTHORIZED=0

in Powershell

$env:HTTPS_PROXY="http://IP:port" << don't use localhost or 127.0.0.1
$env:NODE_TLS_REJECT_UNAUTHORIZED=0

In VSCODE, you can add a settings file (.vscodesettings.json) to specify the environment variable that opens the terminal.

{
    "terminal.integrated.env.windows": {
        "HTTPS_PROXY":"http://IP:port",
        "NODE_TLS_REJECT_UNAUTHORIZED": "0"
    }
}

Hope this will help you: firebase-tools@7.15.1 it works on both win and mac with ssr

1. find your proxy address
WeChatd29e8b5b594f8cff963da7441b84fbc9
1. open "request.js" file in your firebase tools folder. for me, the path is
   /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js
   use "npm root -g" to find your global npm path

2. find the code below, about line 276
  if (!self.hasOwnProperty('proxy')) {
    self.proxy = getProxyFromURI(self.uri)
  }

change it to

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = "http://127.0.0.1:1087";  // this is your proxy address
1. use firebase login --no-localhost

this works for firebase login, but it doesn’t work for firebase init , I cannot list all projects from my google account.

export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;export NO_PROXY=localhost,127.0.0.1

Works for me! Thx.

Mad it work on Mac using this trick

Screen Shot 2019-07-19 at 12 45 14
  1. Go the the network proxy setting on Mac and change Proxy Server and port from CNTL local host to actual enterprise server and port. Screen Shot 2019-07-19 at 13 06 34

  2. No in the terminal temporary authenticate proxy

ProxyPass & ProxyUserName : same as login credentials stored in CNTLM ProxyServer & ProxyPort: same as what you have set in network settings.

export http_proxy=http://<ProxyUserName>:<ProxyPass>@<ProxyServer>:<ProxyPort>
export https_proxy=http://<ProxyUserName>:<ProxyPass>@<ProxyServer>:<ProxyPort>

now I was able to login normally on firebase & deploy cloud functions. Hope it works

The timeout occurs when the Firebase node module makes a connection using faye-websockets, which does not make use of http_proxy and associated environment variables.

There is a comment on StackOverflow that describes how to hard-code the proxy config in faye-websockets as a work-around.

Not elegant, but at least I can deploy now 😃

In the firebase v4.2.0, you can add a proxy server to connent server.

edit the request.js which locate in $NODE_PATH/node_modules/request/request.js:290

// line 290 to 298
 // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = 'http://127.0.0.1:1087'    // add proxy server
  self.tunnel = self._tunnel.isEnabled()
  
  if (self.proxy) {
    self._tunnel.setup(options)
  }

Therefore, Login is success! 😃


Don’t forget delete proxy server setting after login success.

Ok i manage to do something like @namiwang explained before.

Here are some informations about versions i use. node: 7.5.0 npm: 4.1.2 firebase: 3.13.1

firebase-tools is installed globally, so I have to modify the proxy settings where firebase-tools is installed. In my case it is at ~/.nvm/versions/node/v7.5.0/lib/node_modules/firebase-tools

  1. Open file ~/.nvm/versions/node/v7.5.0/lib/node_modules/firebase-tools/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/client.js

  2. Modify lines

  options = options || {};
  this.url     = _url;

to

  options = options || {};
  options.proxy = {
    origin: 'http://user:password@my.proxy.net:3128',
    headers: {'User-Agent': 'node'},
  };
  this.url     = _url;
  1. Go on your project then launch firebase command to deploy
cd ~/workspace/myProject/functions
firebase deploy --only functions

For people who use v2ray for proxy on mac:

  1. Find the proxy in setting: image
  2. Export the proxy in your terminal: export http_proxy=http://localhost:1087 (This is my proxy address)
  3. Find the faye lib in the folder of firebase tool in your global nodejs folder. The path example can be like this. You can find this via search “faye” on your mac. /node_modules/firebase-tools/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/client.js
  4. Add proxy for faye as config. You need to edit the client.js file of faye. var Client = function(_url, protocols, options) { options = options || {}; // Add the proxy here for faye which firebase uses options.proxy = { origin: ‘http://localhost:1087’, }; … } 5.export NODE_TLS_REJECT_UNAUTHORIZED=0 through the terminal 6.firebase login --no-localhost through the terminal

Hope this will help: The main logic here is to tell the faye there is a proxy on my local machine

I work around it via SSH.

I have a VPS so I cloned my project in it and login Firebase. Once I need to deploy new functions, just invoke a remote script via SSH.

Here is some scripts:

  • deployFunctionsRemote.sh in local

    #!/usr/bin/env bash
    
    # funDir point to your functions directory
    funDir=${PROJECT}/functions
    
    # Using rsync cmd to upload local changes to the remote project
    # Excluding node_modules directory is recommend
    cmdLine="rsync -avzPr --rsh='ssh -p ${REMOTE_PORT}' --exclude=node_modules ${funDir} ${REMOTE_USR}@${REMOTE_IP}:${REMOTE_PROJECT}"
    eval ${cmdLine}
    
    # Invoke remote deploy script
    remoteDeployScript=${REMOTE_PROJECT}/deployFunctions.sh
    ssh -p ${REMOTE_PORT} ${REMOTE_USR}@${REMOTE_IP} "${remoteDeployScript}"
    
  • deployFunctions.sh in remote

    #!/usr/bin/env bash
    firebase deploy --only functions
    

Hasta cuando la solución señores de Firebase

I figured out one possible solution that works for those Shadowsocks proxy users(Windows 10 Pro).

1, run “firebase logout” under Shadowsocks PAC Mode;

2, run “firebase login” under Shadowsocks PAC Mode;

3, switch to Shadowsocks Global Mode(which redirects all your request to the remote serve);

4, try “firebase list” to see if the Authentication Error appears or not.

This works for me, but I am not sure whether it helps or not for you. Worth a try.

one year

in Powershell on Windows 10 powered by shadowsocks.

PS> set http_proxy = 'http://127.0.0.1:1080'
PS> set https_proxy = 'http://127.0.0.1:1080'
PS>set NO_PROXY = 'localhost,127.0.0.1'
PS> firebase login

In win10,this works for me, 1080 is my proxy port

Hello guys! Here is another solution which is pretty simple and you don’t need to edit any file. Instead of using Shadowsocks/ShadowsocksR, try SSTap. SSTap creates a virtual network card. I don’t know how to explain, but it works just like that you run Shadowsocks® on your router. Worked for me.

I’m living in China, so it’s really difficult to use Google’s products thanks to GFW. Currently I’m using Shadowsocks listening at 1080 port for accessing Google service.

Here is another problem, if you want to run firebase serve to serve dynamic functions, you cannot use http_proxy=socks5://127.0.0.1:1080, because the localhost request will also be proxied in this way.

I solved this by use only https_proxy=socks5://127.0.0.1:1080,

Summary

Login

firebase login --no-localhost

Serve

export https_proxy=socks5://127.0.0.1:1080
firebase serve

Deploy

Add the follwowing code between BEGIN_PROXY and AFTER_PROXY to your functions/node_modules/faye-websocket/lib/faye/websocket/client.js

// ...
var Client = function(_url, protocols, options) {
  options = options || {};

  // BEGIN_PROXY
  options.proxy = {
    origin:  'http://localhost:8888',
    headers: {'User-Agent': 'node'},
  }
  // AFTER_PROXY

// ...
firebase deploy
Click to see my log
upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase login --no-localhost
? Allow Firebase to collect anonymous CLI usage and error reporting
 information? No

Visit this URL on any device to log in:
https://accounts.google.com/o/oauth2/auth?client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=928286882&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob

? Paste authorization code here: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

+  Success! Logged in as upupming@gmail.com

upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase serve

=== Serving from 'E:\github\firebase-test'...

i  functions: Preparing to emulate functions.
i  hosting: Serving hosting files from: public
+  hosting: Local server: http://localhost:5000
Warning: You're using Node.js v8.11.3 but Google Cloud Functions only supports v6.11.5.
+  functions: app: http://localhost:5001/learning-13a18/us-central1/app
127.0.0.1 - - [08/Nov/2018:04:40:35 +0000] "GET / HTTP/1.1" 200 3505 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:37 +0000] "GET /__/firebase/init.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:37 +0000] "GET /__/firebase/5.5.7/firebase-app.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:38 +0000] "GET /__/firebase/5.5.7/firebase-auth.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:38 +0000] "GET /__/firebase/5.5.7/firebase-messaging.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:38 +0000] "GET /__/firebase/5.5.7/firebase-database.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:39 +0000] "GET /__/firebase/5.5.7/firebase-storage.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:40 +0000] "GET /favicon.ico HTTP/1.1" 404 1808 "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0;
Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
[hosting] Rewriting /timestamp to local function app
info: User function triggered, starting execution
info: Execution took 23 ms, user function completed successfully
127.0.0.1 - - [08/Nov/2018:04:40:41 +0000] "GET /timestamp HTTP/1.1" 200 13 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
[hosting] Rewriting /timestamp to local function app
info: User function triggered, starting execution
info: Execution took 2 ms, user function completed successfully
127.0.0.1 - - [08/Nov/2018:04:40:43 +0000] "GET /timestamp HTTP/1.1" 200 13 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
Shutting down...


upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ export http_proxy=socks5://127.0.0.1:1080

upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase serve

Error: Server Error. socket hang up

upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ export http_proxy=

upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase serve

=== Serving from 'E:\github\firebase-test'...

i  functions: Preparing to emulate functions.
i  hosting: Serving hosting files from: public
+  hosting: Local server: http://localhost:5000
Warning: You're using Node.js v8.11.3 but Google Cloud Functions only supports v6.11.5.
+  functions: app: http://localhost:5001/learning-13a18/us-central1/app
Shutting down...


upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase deploy

Error: Server Error. socket hang up

upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase deploy

=== Deploying to 'learning-13a18'...

i  deploying functions, hosting
Running command: npm --prefix "%RESOURCE_DIR%" run lint

> functions@ lint E:\github\firebase-test\functions
> eslint .

+  functions: Finished running predeploy script.
i  functions: ensuring necessary APIs are enabled...
+  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (52.46 KB) for uploading
+  functions: functions folder uploaded successfully
i  hosting[learning-13a18]: beginning deploy...
i  hosting[learning-13a18]: found 2 files in public
+  hosting[learning-13a18]: file upload complete
i  functions: updating Node.js 6 function app(us-central1)...
+  functions[app(us-central1)]: Successful update operation.
i  hosting[learning-13a18]: finalizing version...
+  hosting[learning-13a18]: version finalized
i  hosting[learning-13a18]: releasing new version...
+  hosting[learning-13a18]: release complete

+  Deploy complete!

Project Console: https://console.firebase.google.com/project/learning-13a18/overviewHosting URL: https://learning-13a18.firebaseapp.com

Alternative solution

If you are always using home WiFi network, you can config Shadowsocks proxy on your router. See this repo for more information.

I hope to have some good news on this front when some infrastructure work we’re doing now comes through. I don’t have a specific timeline to provide, however.

Sorry for the long delay in addressing this issue, it has been much more complicated than you’d think.

On Fri, Jun 29, 2018, 1:12 AM noobhui notifications@github.com wrote:

so, I have to give up using firebase? In China , without proxy I can not even search in google. As if i have seen a crystal cake , I can not eat .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-tools/issues/155#issuecomment-401282471, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAD_hDs8s1zUkv3-8QFYSxcvCFrNFs2ks5uBeFagaJpZM4InPdh .

Confirming that this works

This worked for me!

set “NODE_TLS_REJECT_UNAUTHORIZED=0”

Hey,upstairs brother,can you speak English ?

Same problem…

Still unable to solve the issue(in China), tried most of the answers.

image !!!!! if PowerShell, PS C:\Users\86205> $env:http_proxy = ‘http://127.0.0.1:11199’ PS C:\Users\86205> $env:https_proxy = ‘http://127.0.0.1:11199’ PS C:\Users\86205> $env:NO_PROXY = ‘localhost,127.0.0.1’ PS C:\Users\86205> firebase login

Hope this will help you:

steps are the same as before. The new file location: …/firebase-tools/lib/api.js

find the code below, around line 297

reqOptions.headers = options.headers; reqOptions.timeout = options.timeout;

append reqOptions.proxy = "http://127.0.0.1:10818";

run firebase login --no-localhost

Same issue.

still experiencing this issue, can’t believe it is still around in 2020 …

I’m living in China, so it’s really difficult to use Google’s products thanks to GFW. Currently I’m using Shadowsocks listening at 1080 port for accessing Google service.

Here is another problem, if you want to run firebase serve to serve dynamic functions, you cannot use http_proxy=socks5://127.0.0.1:1080, because the localhost request will also be proxied in this way.

I solved this by use only https_proxy=socks5://127.0.0.1:1080,

Summary

Login

firebase login --no-localhost

Serve

export https_proxy=socks5://127.0.0.1:1080
firebase serve

Deploy

Add the follwowing code between BEGIN_PROXY and AFTER_PROXY to your functions/node_modules/faye-websocket/lib/faye/websocket/client.js

// ...
var Client = function(_url, protocols, options) {
  options = options || {};

  // BEGIN_PROXY
  options.proxy = {
    origin:  'http://localhost:8888',
    headers: {'User-Agent': 'node'},
  }
  // AFTER_PROXY

// ...
firebase deploy

Click to see my log

Alternative solution

If you are always using home WiFi network, you can config Shadowsocks proxy on your router. See this repo for more information.

In the firebase v4.2.0, you can add a proxy server to connent server.

edit the request.js which locate in $NODE_PATH/node_modules/request/request.js:290

// line 290 to 298
 // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = 'http://127.0.0.1:1087'    // add proxy server
  self.tunnel = self._tunnel.isEnabled()
  
  if (self.proxy) {
    self._tunnel.setup(options)
  }

Therefore, Login is success! 😃

Don’t forget delete proxy server setting after login success.

Great!!!

Alright, I add another issue #883 for socks proxy support.

I know some applications also support environment variables for socks proxy, like: export http_proxy=socks5://127.0.0.1:1080 https_proxy=socks5://127.0.0.1:1080

Hope firebase command support it too.

share my solution for who work inside and wanna live outside the GFW.

Env: MacOS with shadowsocks-ng

~/.bash_profile

alias cbrew="ALL_PROXY=socks5://127.0.0.1:1086 brew"

# using polipo
alias cfirebase="http_proxy=http://127.0.0.1:8123 firebase"

# your shadowsocks may already have http proxy feature
alias cfirebase="http_proxy=http://127.0.0.1:1087 firebase"

up polipo http proxy (optional)

cbrew install polipo
polipo socksParentProxy=localhost:1086 &

login

cfirebase login --debug

polyfill faye-websocket

Thanks @namiwang it works.

because firebase sdk 2.x.x is minified, so… polyfill faye-websocket is easier than fix sdk.

// if you installed node by brew, the path would be /usr/local/lib/node_modules/firebase-tools/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/client.js
...
var proxy_uri = process.env.http_proxy
if (proxy_uri) {
  options.proxy = { origin: proxy_uri }
}
...

deploy

cfirebase deploy --only functions --debug

Actually, newer firebase sdk already fixed the bug. Waiting firebase-tools up deps to date…

we need a proxy option in firebase tools when firebase login

I am not running behind a proxy but i am seeing this issue. I am getting the following error while deploying the code. ** Error: Server Error. connect ETIMEDOUT 172.217.31.202:443

So i did “firebase login --reauth” and provided correct credentials, but when i executed “firebase list” I got the following error even though I was logged in successfully. **Error: Authentication Error: Your credentials are no longer valid. Please run firebase login --reauth

Then i followed the following steps to resolve the issue. firebase logout firebase login -> Successful login firebase list -> I can see my apps firebase deploy -> I can deploy the code successfully.

As about “firebase deploy” - still have this issue. No errors, it just hangs.

I have the same problem, the firebase team just write me this:

“Not possible at the moment, tracking here: https://github.com/firebase/firebase-tools/issues/155 but no timeline on a fix.”

Actually referring me to this page XP

Hope this will be fix soon, since many of us developers use this tools at work

Update. Just made login working.

  1. run Git Bash or any Linux-like command line tool
  2. execute these commands, substitute your proxy instead

export HTTP_PROXY=“http://proxy.XXXXXXXX.com:80/” export HTTPS_PROXY=“http://proxy.XXXXXXXX.com:80/

  1. after this I was able to login using

firebase login --interactive

  1. useful links

#36 (comment) https://www.npmjs.com/package/request#controlling-proxy-behaviour-using-environment-variables

I’m in China. I tried so many answers from various sources for 3-4 months(day after few days). Nothing worded. Only it works from git-bash. Thanks a million.

in Powershell on Windows 10 powered by shadowsocks.

PS> set http_proxy = 'http://127.0.0.1:1080'
PS> set https_proxy = 'http://127.0.0.1:1080'
PS>set NO_PROXY = 'localhost,127.0.0.1'
PS> firebase login

In win10,this works for me, 1080 is my proxy port

it works !!! thank you !!(ps i’m on mac)

This solution still works as of today. I recommend following these steps to identify YOUR proxy address: https://suitabletech.com/support/helpcenter/errors-full-listing/1895-locating-proxy-server-ip-address-windows

Thank you.

  1. set proxy image 2 . C:\Users\admin\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\request\request.js

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }

  self.proxy = "http://127.0.0.1:4780";  // this is your proxy address

image

  1. use firebase login , Success!

image

after set proxy. auth failed. my proxy is ftp=127.0.0.1:9999;gopher=127.0.0.1:9999;http=127.0.0.1:9999;https=127.0.0.1:9999;socks=127.0.0.1:10000;lq=1 image

Mad it work on Mac using this trick Screen Shot 2019-07-19 at 12 45 14

  1. Go the the network proxy setting on Mac and change Proxy Server and port from CNTL local host to actual enterprise server and port.
Screen Shot 2019-07-19 at 13 06 34
  1. No in the terminal temporary authenticate proxy

ProxyPass & ProxyUserName : same as login credentials stored in CNTLM ProxyServer & ProxyPort: same as what you have set in network settings.

export http_proxy=http://<ProxyUserName>:<ProxyPass>@<ProxyServer>:<ProxyPort>
export https_proxy=http://<ProxyUserName>:<ProxyPass>@<ProxyServer>:<ProxyPort>

now I was able to login normally on firebase & deploy cloud functions. Hope it works

Thanks for this, I use “set” instead of “export” in windows, and it works

set http_proxy=http://127.0.0.1:port set https_proxy=http://127.0.0.1:port

20210718011812

You sir are a genius! Thank you!

This worked for me. I’m in China using clash for windows as a proxy. I ran the command prompt as an administrator and set the proxies. Worked first time.

Legend!

Sooo… They just don’t care about proxy users? Old way was to downgrade to firebase-tools@8.15.0, but that does not work because of Authentication error the site gives, because of “The version of the app you’re using doesn’t include the latest security features to keep you protected.”

This has to be a joke.

Thank you.

  1. set proxy image 2 . C:\Users\admin\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\request\request.js

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }

  self.proxy = "http://127.0.0.1:4780";  // this is your proxy address

image

  1. use firebase login , Success!

image

still experiencing this issue, can’t believe it is still around in 2022 …

Hope this will help you: firebase-tools@7.15.1 it works on both win and mac with ssr

  1. find your proxy address
WeChatd29e8b5b594f8cff963da7441b84fbc9
  1. open “request.js” file in your firebase tools folder. for me, the path is /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js use “npm root -g” to find your global npm path
  2. find the code below, about line 276
  if (!self.hasOwnProperty('proxy')) {
    self.proxy = getProxyFromURI(self.uri)
  }

change it to

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = "http://127.0.0.1:1087";  // this is your proxy address
  1. use firebase login --no-localhost

FINALLY WORKS!!! Thanks a ton!!!🌷🌷🌷

Hello, I just found the solution. Please follow the link https://qiita.com/tanoc/items/ac92464de473ae483d50

failed, not work

Hello guys! Here is another solution which is pretty simple and you don’t need to edit any file. Instead of using Shadowsocks/ShadowsocksR, try SSTap. SSTap creates a virtual network card. I don’t know how to explain, but it works just like that you run Shadowsocks® on your router. Worked for me.

@yqx1110 Thanks very much, this is the most powerful tool I have ever seen.

export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;export NO_PROXY=localhost,127.0.0.1

Worked for me behind shadowsocks in China. Thanks!

All right folks, it’s time to fix this bug once and for all! With the release of v4.1.0, the Firebase CLI no longer depends on a websocket connection for Hosting deploys. That means that everything is done through standard HTTP requests, which should be able to be easily made to work with proxies.

I am going to try to get a test proxy running locally to work on this myself, but for those affected:

  1. Does v4.1.0 “just work” or are you still having errors?
  2. Does setting the HTTPS_PROXY environment variable work for you?

I know it’s been a long road, but (I hope) it will be coming to an end very soon. Please report back with your experience with 4.1.0, and we’ll start working through any remaining problems!

很难受 还没解决- -?

Cool. Could we do something like this though?

if (process.env.HTTP_SERVER) {
   options.proxy = {
      origin: process.env.HTTP_SERVER,
      headers: { 'User-Agent': 'node' }
   };
}

same here i solved this by sharing my mobile network…

Same problem 😦

Same for me, pretty sad deploy is not working behind a proxy 😦. Firebase tools are still awesome though

This P2 bug lives for one and half years.

I can only count on Good luck when debugging, tired of retrying login again and again, it has seriously delayed my project, I have to build my own server now.