Closed davemasterdave closed 2 months ago
Hello @davemasterdave. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro
will be closed if they have no activity within 3 days.
+1, meet same issue with astro:env
PS: currently I use import.meta.env
as a temporary workaround.
+1, meet same issue with astro:env
PS: currently I use
import.meta.env
as a temporary workaround.
@cielorz I am actually trying to switch the adaptor to run on Cloudflare Pages/Edge instead of Node.js, the import.meta.env
workaround unfortunately does not work on Cloudflare it seems. What do you recommend?
+1, meet same issue with astro:env PS: currently I use
import.meta.env
as a temporary workaround.@cielorz I am actually trying to switch the adaptor to run on Cloudflare Pages/Edge instead of Node.js, the
import.meta.env
workaround unfortunately does not work on Cloudflare it seems. What do you recommend?
I use Cloudflare adapter either, import.meta.env
should work fine. this code works in my project.
import { createDirectus, rest, staticToken } from '@directus/sdk';
import { type DirectusSchema } from './schemas/';
// import { DIRECTUS_API_URL } from 'astro:env/client';
// import { DIRECTUS_AUTH_TOKEN } from 'astro:env/server';
// Use import.meta.env as a workaround
const DIRECTUS_API_URL = import.meta.env.DIRECTUS_API_URL;
const DIRECTUS_AUTH_TOKEN = import.meta.env.DIRECTUS_AUTH_TOKEN;
const directus = createDirectus<DirectusSchema>(DIRECTUS_API_URL)
.with(rest())
.with(staticToken(DIRECTUS_AUTH_TOKEN));
export { directus };
Reproduction:
npm run astro sync
I think it's caused by https://github.com/withastro/astro/blob/main/packages/astro/src/env/vite-plugin-env.ts#L34. Instead of returning early if we sync, we should just skip validation
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Astro environments are not working in the configuration for Content Collections
config.ts
. It seems that the generation code for the Content Collections is running before the generation code for the environment variables runs, therefore the content collection generation process is breaking? It seems that the environments needs to be fully generated first before the content collections generate?What's the expected result?
Environment variables are useful for dynamically configuring where content should be loaded from, and the astro:env module should be accessible for the code based content configuration
Link to Minimal Reproducible Example
pending
Participation