Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hosting doesn't take dotenv files from different environments #7207

Closed
yanqianglu opened this issue May 22, 2024 · 3 comments
Closed

Hosting doesn't take dotenv files from different environments #7207

yanqianglu opened this issue May 22, 2024 · 3 comments

Comments

@yanqianglu
Copy link

yanqianglu commented May 22, 2024

[REQUIRED] Environment info

firebase-tools: 13.10.0

Platform: macOS

[REQUIRED] Test case

See "Steps to reproduce" below.

[REQUIRED] Steps to reproduce

# .firebaserc
{
  "projects": {
    "prod": "my-project-prod",
    "stg": "my-project-stg"
  }
}
# .envfile
FOO_1=BAR
# .env.stg file
FOO_2=BAR

[REQUIRED] Expected behavior

It should take the .env.stg file as part of the build.

> firebase use stg && firebase deploy

  ▲ Next.js 14.2.3

  - Environments: .env, .env.stg


   Creating an optimized production build ...

 ✓ Compiled successfully

   Linting and checking validity of types ...

...


i  functions: Loaded environment variables from .env, .env.stg.

[REQUIRED] Actual behavior

It only takes .env file and ignored .env.stg file. The .env.stg is included as part of the functions deployment though.

> firebase use stg && firebase deploy

  ▲ Next.js 14.2.3

  - Environments: .env


   Creating an optimized production build ...

 ✓ Compiled successfully

   Linting and checking validity of types ...


...



i  functions: Loaded environment variables from .env, .env.stg.
@google-oss-bot
Copy link
Contributor

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

@chalosalvador
Copy link
Member

@yanqianglu If your pages use SSR you can rename your dotenv file to .env.<PROJECT-ID> instead of .env.<PROJECT-ALIAS> and you should be able to read the environment variables in that file. You can read more about it in the Parameterized configuration for Cloud Functions.

I have opened a PR (#7323) to handle the issue when using SSG in Next.js. But the idea is the same, we would read the values from the .env.<PROJECT-ID>.

@chalosalvador
Copy link
Member

@yanqianglu the PR #7323 with the fix has been merged and will be available in the next CLI release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants