“Firebase -Umgebungsvariablen” Code-Antworten

Firebase Env

On .env.local file you have to write
//All "" will have to remove
REACT_APP_FIREBASE_API_KEY=
REACT_APP_FIREBASE_AUTH_DOMAIN=
REACT_APP_FIREBASE_PROJECT_ID=
REACT_APP_FIREBASE_STORAGE_BUCKET=
REACT_APP_FIREBASE_MESSAGING_SENDER_ID=
REACT_APP_FIREBASE_APP_ID=
Zany Zebra

Firebase Env

const firebaseConfig = {
    apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
    authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
    projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
    storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
    messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
    appId: process.env.REACT_APP_FIREBASE_APP_ID,
  };
  
  Then import it otherwise it will not work
Zany Zebra

Firebase -Umgebungsvariablen

$ cd project_directory
$ cd functions
$ firebase functions:config:set api_key1="YOUR_API_KEY1" api_key2="YOUR_API_KEY2"

// Accessing the Keys in Code

const functions = require('firebase-functions');

const api_key1  = functions.config().api_key1;
const api_key2  = functions.config().api_key2;
Inquisitive Iguana

Firebase Funktionen config

const functions = require('firebase-functions');const request = require('request-promise');exports.userCreated = functions.database.ref('/users/{id}').onWrite(event => {  let email = event.data.child('email').val();  return request({    url: 'https://someservice.com/api/some/call',    headers: {      'X-Client-ID': functions.config().someservice.id,      'Authorization': `Bearer ${functions.config().someservice.key}`    },    body: {email: email}  });});
Dangerous Dormouse

Ähnliche Antworten wie “Firebase -Umgebungsvariablen”

Fragen ähnlich wie “Firebase -Umgebungsvariablen”

Weitere verwandte Antworten zu “Firebase -Umgebungsvariablen” auf Shell/Bash

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen