-
Notifications
You must be signed in to change notification settings - Fork 12
fix(build): pass VITE_PRIVY_APP_ID env var to fix Privy app ID on staging #499
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
base: staging
Are you sure you want to change the base?
Conversation
…ging - Add VITE_PRIVY_APP_ID to build script to ensure Cloudflare Pages env var is passed to Vite - Fixes issue where staging was using dev Privy app ID instead of production app ID - Vite doesn't automatically load system env vars, they must be explicitly passed
📝 WalkthroughWalkthroughThe build script now passes VITE_PRIVY_APP_ID to the Vite build. The Vite config was converted to a function-based export that calls loadEnv(...) to expose VITE_PRIVY_APP_ID via define, and test settings now include a global define and pool: 'forks'. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying pillarx-debug with
|
| Latest commit: |
316152f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://72cf3feb.pillarx-debug.pages.dev |
| Branch Preview URL: | https://fix-privy-app-id-env-var.pillarx-debug.pages.dev |
Deploying x with
|
| Latest commit: |
316152f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f1015846.x-e62.pages.dev |
| Branch Preview URL: | https://fix-privy-app-id-env-var.x-e62.pages.dev |
…nment - Update vite.config.js to use loadEnv() function - Explicitly define VITE_PRIVY_APP_ID in the define section - This ensures environment variables from Cloudflare Pages are properly loaded - Fallback from Option 1 which didn't work on Cloudflare Pages
- Change to use process.env.VITE_PRIVY_APP_ID with fallback to loadEnv - Ensures Cloudflare Pages system environment variables take priority - Fixes issue where loadEnv was using dev mode instead of production env vars
Problem
Staging was using the dev Privy App ID (clx07qnbf07qdwlja56mg55er) instead of the production Privy App ID, even though the environment variable is configured in Cloudflare Pages.
Root Cause
Vite doesn't automatically load system environment variables during the build process. The build script was only explicitly passing VITE_COMMIT_SHA and VITE_VERSION, but not VITE_PRIVY_APP_ID. This caused Vite to fall back to loading the value from .env.example, which contains the dev app ID.
Changes
Updated the build script in package.json to explicitly pass the VITE_PRIVY_APP_ID environment variable:
This ensures that when Cloudflare Pages runs the build, it will pass the VITE_PRIVY_APP_ID environment variable (configured in Cloudflare Pages settings) to Vite, which will then embed it in the built application.
Testing
✅ Tested locally by building with a test production app ID
✅ Verified the test app ID is embedded in the built JavaScript
✅ Confirmed the dev app ID is NOT in the build
Verification Steps
After merging:
Summary by CodeRabbit
Chores
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.