Astro.js .env.production Access on Fly.io

I’m trying to deploy an Astro application to Fly.io that uses a .env file for local settings and a .env.production for production settings / secrets.

After deploying, it seems that the .env.production variables are not accessible when the program uses import.meta.env.PUBLIC_APP_ID for example.

How can I utilize .env.production with fly.io?

I don’t think import.meta.env.PUBLIC_APP_ID would read from the fly secrets, so I’m not sure where to go.

  1. Don’t use .env for secrets :sleeping:
  2. Do astro automatically load .env (via dotenv or something)
  3. Does it load those env at build time?

Thanks! So use real environment variables instead of .env, I can make that switch. (Or is there some other preferred mechanism?)

Astro uses Vite’s environment variable support and statically replaces them at build time. Not sure if that means using dotenv.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.