Skip to content

astro:env secrets may throw on static pages #12581

@florian-lefebvre

Description

@florian-lefebvre

📚 Subject area/topic

astro:env

📋 Page(s) affected (or suggested, for new content)

https://docs.astro.build/en/guides/environment-variables/

📋 Description of content that is out-of-date or incorrect

See #14504 for context. If you are in such situation:

  • You have public and secret server vars
  • You do not use secrets on prerendered pages
  • You use public server vars on prerendered pages
  • You do not provide secrets during the build since they're not technically required
  • You do not have env.validateSecrets: true

Then an error will be thrown saying that your secrets are missing. That's because as soon as the astro:env/server module is imported, even secrets are evaluated. There's nothing we can do about it unfortunately.

Solution is to pass fake values during the build to avoid errors.

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    improve or update documentationEnhance / update existing documentation (e.g. add example, improve description, update for changes)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions