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

astro:env showing undefined vars in production mode #13009

Open
1 task
daspete opened this issue Jan 20, 2025 · 0 comments
Open
1 task

astro:env showing undefined vars in production mode #13009

daspete opened this issue Jan 20, 2025 · 0 comments
Labels
feat: env related to the way astro handles `.env` or `import.meta.env` or `process.env` (scope) pkg: node Related to Node adapter (scope)

Comments

@daspete
Copy link

daspete commented Jan 20, 2025

Astro Info

Astro                    v5.1.7
Node                     v22.13.0
System                   Linux (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/node
Integrations             astro-icon
                         @astrojs/tailwind
                         @astrojs/vue

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

i defined a schema for some environment variables in the astro.config.mjs file.
When i run the project in dev mode, the import from the astro:env package works, for example like this:

import { API_URL } from 'astro:env/client'

But when i run the build and then start with

node ./dist/server/entry.mjs

the API_URL get's undefined, even there is the variable set in process.env

In the stackblitz example, you can just run:

npm run build
npm run start

to see the result.

What's the expected result?

The variables set with astro:env should not be undefined on production runtime.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-f34drayg?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 20, 2025
@ascorbic ascorbic added pkg: node Related to Node adapter (scope) feat: env related to the way astro handles `.env` or `import.meta.env` or `process.env` (scope) and removed needs triage Issue needs to be triaged labels Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: env related to the way astro handles `.env` or `import.meta.env` or `process.env` (scope) pkg: node Related to Node adapter (scope)
Projects
None yet
Development

No branches or pull requests

2 participants