Repository navigation
fix(desktop): bake OAuth client IDs into main process at build time - #433
Conversation
GOOGLE_CLIENT_ID and GH_CLIENT_ID were being passed during build but not embedded into the main process bundle. Added them to the vite define block so they're available at runtime in the packaged app. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
WalkthroughExpose four additional environment variables to the desktop Electron build: NEXT_PUBLIC_API_URL, NEXT_PUBLIC_WEB_URL, GOOGLE_CLIENT_ID, and GH_CLIENT_ID. Changes add build-time defines and an explicit runtime env listing; no control-flow or runtime logic changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
…ment The spread of process.env only works at runtime but is empty in bundled apps. Each env var must be explicitly listed so Vite can replace the process.env.X references at build time. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/desktop/src/main/env.main.ts (1)
19-20: Add fallback defaults or explicit validation for OAuth client IDs to match other environment variables.
GOOGLE_CLIENT_IDandGH_CLIENT_IDare injected without fallback defaults in the Vite configuration (lines 69-72), whileNEXT_PUBLIC_API_URLandNEXT_PUBLIC_WEB_URLhave explicit fallbacks (lines 62-67). Either add fallback values for the OAuth IDs or add explicit build-time validation to ensure these critical variables are always defined, preventing undefined values from being stringified into the bundle.
🧹 Nitpick comments (1)
apps/desktop/src/main/env.main.ts (1)
23-32: Explicit environment variable listing enables correct build-time replacement.The explicit listing of environment variables (lines 27-31) correctly enables Vite to perform build-time substitution for bundled apps, and the comment clearly explains the rationale. This approach properly addresses the PR objective of baking OAuth client IDs into the bundle.
Optional refactor: Consider removing the
process.envspread.The spread of
process.envon line 24 may be redundant if only the schema-defined variables are needed. All validated variables are now explicitly listed below. Removing the spread would make the code clearer and ensure only validated variables are accessed.🔎 Proposed refactor to remove redundant spread
runtimeEnv: { - ...process.env, // Explicitly list env vars so Vite can replace them at build time // (spreading process.env only works at runtime, not for bundled apps) NODE_ENV: process.env.NODE_ENV, NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL, NEXT_PUBLIC_WEB_URL: process.env.NEXT_PUBLIC_WEB_URL, GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID, GH_CLIENT_ID: process.env.GH_CLIENT_ID, },Only apply this change if no additional unvalidated environment variables need to be accessible in the main process.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/desktop/electron.vite.config.ts(1 hunks)apps/desktop/src/main/env.main.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/desktop/electron.vite.config.ts
🧰 Additional context used
📓 Path-based instructions (5)
apps/desktop/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)
apps/desktop/**/*.{ts,tsx,js,jsx}: For Electron interprocess communication, ALWAYS use trpc as defined insrc/lib/trpc
Use alias as defined intsconfig.jsonwhen possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary.
Files:
apps/desktop/src/main/env.main.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Avoid using any type in TypeScript - maintain type safety unless absolutely necessary
Files:
apps/desktop/src/main/env.main.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Run Biome for formatting, linting, import organization, and safe fixes at the root level using bun run lint:fix
Files:
apps/desktop/src/main/env.main.ts
apps/desktop/src/{main,renderer,preload}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use type-safe IPC communication - define channel types in apps/desktop/src/shared/ipc-channels.ts before implementing handlers
Files:
apps/desktop/src/main/env.main.ts
apps/desktop/src/main/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Accept object parameters in IPC handlers - do not use positional parameters in ipcMain.handle()
Files:
apps/desktop/src/main/env.main.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T23:19:10.405Z
Learning: Applies to apps/desktop/src/main/index.ts : Load environment variables in src/main/index.ts and electron.vite.config.ts with override: true before other imports
📚 Learning: 2025-12-18T23:19:10.405Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T23:19:10.405Z
Learning: Applies to apps/desktop/src/main/index.ts : Load environment variables in src/main/index.ts and electron.vite.config.ts with override: true before other imports
Applied to files:
apps/desktop/src/main/env.main.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build - macOS (arm64)
- GitHub Check: Build
Summary
GOOGLE_CLIENT_IDandGH_CLIENT_IDto the vitedefineblock for main processprocess.envat runtimeTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.