-
- Add Project
-
Add Firebase to your app
{ Example response
<script>
// Initialize Firebase
var config = {
apiKey: "xxxxxx",
authDomain: "xxxxxx.firebaseapp.com",
databaseURL: "https://xxxxxx.firebaseio.com",
projectId: "xxxxxx",
storageBucket: "xxxxxx.appspot.com",
messagingSenderId: "xxxxxx"
};
firebase.initializeApp(config);
</script>
}
- Add apiKey, authDomain, databaseURL, projectId, and storageBucket in .env file
-
Setup public access to your Firebase database & Storage
- firebase console -> Database tab -> Rules tab
- rules:
{ "rules": { ".read": "auth == null", ".write": "auth == null" } }
- firebase console -> Storage tab -> Rules tab
- rules:
service firebase.storage { match /b/{bucket}/o { match /{allPaths=**} { allow read, write; } } }
-
Create a Cloud Storage project by using the drop down on the top left next to Google Cloud Platform logo
-
Click on the Credentials tab, create a new credential file
-
Service account key
- Service account: App Engine default service account
- Key type: JSON
-
Your private key .json file should automatically download
-
-
Rename and store private key file as private_key.json file in the server's main directory, ADD TO .gitignore!!
-
Add private_key.json filename as STORAGE_KEY_FILENAME into .env file
$ npm install
$ nodemon ./server.js localhost 5000
$ npm start