firebase网络问题解决方案

2018-04-30  本文已影响90人  kelvv

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

上一篇 下一篇

猜你喜欢

热点阅读