npm install firebase-admin-proxy --save
const caw = require("caw");
const https = require("https");
// Your Proxy
const firebaseAgent = caw("http://127.0.0.1:8118", {
protocol: "https",
});
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://YOURAPP.firebaseio.com",
agent: firebaseAgent, // proxy agent
logging_enabled: true, // open logging info
});
If logging_enabled
is open, your console will print out a similar log:
p:0: Browser went online.
p:0: Listen called for /users default
p:0: Making a connection attempt
p:0: Auth token refreshed
getToken() completed. Creating connection.
c:0:0: Connection created
c:0:0:0 Websocket connecting to wss://YOURAPP.firebaseio.com/.ws?v=5
c:0:0:0 Websocket connected.
c:0:0: Reset packet received. New host: XXXXX.firebaseio.com
c:0:0: Shutting down all connections
c:0:0:0 WebSocket is being closed
c:0:0:0 Websocket connection was disconnected.
c:0:0:1 Websocket connecting to wss://XXXXX.firebaseio.com/.ws?v=5&ns=YOURAPP
c:0:0:1 Websocket connected.
c:0:0: Realtime connection established.
p:0: connection ready
Find YOURAPP.firebaseio.com
and XXXXX.firebaseio.com
real ID and add them to the hosts file.
Firebase provides the tools and infrastructure you need to develop your app, grow your user base, and earn money. The Firebase Admin Node.js SDK provides admin (second-party) access to several Firebase services.
For more information, visit the Firebase Admin SDK setup guide.
The Firebase Admin Node.js SDK is available on npm as firebase-admin
:
$ npm install --save firebase-admin
To use the module in your application, require
it from any JavaScript file:
var admin = require("firebase-admin");
If you are using ES2015, you can import
the module instead:
import * as admin from "firebase-admin";
Release Notes for the Firebase Admin Node.js SDK are available here.
Thanks to the team at Casetext for transferring
ownership of the firebase-admin
npm module over to the Firebase team
and for their longtime use and support of the Firebase platform.
The Firebase Admin Node.js SDK is covered by the Terms of Service for Firebase Services.