Firebase Cloud Functions Environment Variables

Firebase Cloud Functions

For Firebase Cloud Functions, you can set environment configuration via

firebase functions:config:set nuxtssr.runtime_api_url="https://PROJECT.firebaseapp.com"

NOTE: key must be lowercase

NOTE: Run firebase functions:config:get to check existing configurations

To access environment configuration

functions/index.js

const config = functions.config();process.env.RUNTIME_API_URL = config.nuxtssr.runtime_api_url;

To setup environment configuration for local development

Edit functions/.runtimeconfig.json

{  "nuxtssr": {    "runtime_api_url": "http://localhost:5000"  }}

Google Cloud Functions

For Google Cloud Functions, you can set environment variables via

gcloud functions deploy FUNCTION_NAME --set-env-vars RUNTIME_API_URL="https://PROJECT.firebaseapp.com"

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.