skip to Main Content

I’m new to Firebase and I’m planning to create 2 Firebase projects, 1 for test environment and 1 for production environment. I want to deploy a NextJS web app and while I understand that I can use the same codebase and link it to 2 projects, I can only see that in this doc, it’s reliant on apphosting.yaml for environment variables and secrets, but it will be checked in git. So that means we only have 1 set of values regardless of which Firebase project we’re in.

How do I create different sets of env variables and secrets for each project? Or am I approaching this the wrong way?

I’m still in planning stage, only reading through the documents, so I don’t know how to start.

2

Answers


  1. Chosen as BEST ANSWER

    Google Cloud Secret Manager, which apphosting.yaml reads value from, can store values independently in each Firebase project. So making it possible to have different config for the same codebase.


  2. I created an apphosting.yaml and created a secret in "secret manager" named "CURRENT_ENVIRONMENT" that would have either dev or prod

    apphosting.yaml

    env:
      - variable: CURRENT_ENV
        secret: CURRENT_ENVIRONMENT
        availability:
          - BUILD
          - RUNTIME
    

    Next i ran this command on each enviroment (firebase use dev & firebase use prod) to make it available.

    firebase --backend {your backend id} apphosting:secrets:grantaccess CURRENT_ENVIRONMENT

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search