fix(astro): Fall back to process.env for runtime environment variables#7889
fix(astro): Fall back to process.env for runtime environment variables#7889alexcarpenter wants to merge 4 commits intomainfrom
Conversation
Add process.env as a third fallback in getContextEnvVar() so that PUBLIC_CLERK_PUBLISHABLE_KEY and other env vars set at runtime (e.g., via the Astro Node adapter) are properly read when import.meta.env.PUBLIC_* is statically replaced at build time by Vite. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
🦋 Changeset detectedLatest commit: 16d0346 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughThe PR adds a runtime fallback in the Astro integration's getContextEnvVar(): it reads import.meta.env first and, if that value is missing, falls back to process.env; returns undefined if neither is present. Tests for getSafeEnv and getClientSafeEnv were added to verify source precedence, keylessPublishableKey precedence, and fallback behavior for publishable and public env vars across runtime contexts. Possibly related issues
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Add process.env as a third fallback in getContextEnvVar() so that PUBLIC_CLERK_PUBLISHABLE_KEY and other env vars set at runtime (e.g., via the Astro Node adapter) are properly read when import.meta.env.PUBLIC_* is statically replaced at build time by Vite. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…script into ac/astro-process-env-fallback # Conflicts: # packages/astro/src/server/__tests__/get-safe-env.test.ts
Use `as unknown as App.Locals` cast in createLocals to avoid strict assignability errors from Partial<App.Locals> spreading. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
Add process.env as a third fallback in getContextEnvVar() so that PUBLIC_CLERK_PUBLISHABLE_KEY and other env vars set at runtime (e.g., via the Astro Node adapter) are properly read when import.meta.env.PUBLIC_* is statically replaced at build time by Vite.
Description
fixes #7841
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
Bug Fixes
Tests