Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(web): resolve NEXTJS_ENV at build time for client auth mode
Gener0c2532df7c61
diff --git a/src/web/next.config.ts b/src/web/next.config.tsindex 418e01721..18bd497a0 100644--- a/src/web/next.config.ts+++ b/src/web/next.config.ts@@ -1,10 +1,32 @@import type { NextConfig } from "next";import path from "node:path";+import { readFileSync } from "node:fs";++// Resolve NEXTJS_ENV for client bundles. Wrangler bindings are runtime-only,+// so we read the value at build/dev time from .dev.vars (overrides) → wrangler.toml.+function resolveEnv(key: string): string | undefined {+ if (process.env[key]) return process.env[key];+ const dir = __dirname;+ // .dev.vars overrides wrangler.toml (same precedence wrangler uses)+ for (const file of [".dev.vars", "wrangler.toml"]) {+ try {+ const content = readFileSync(path.resolve(dir, file), "utf-8");+ const match = content.match(new RegExp(`^${key}\\s*=\\s*"?([^"\\n]*)"?`, "m"));+ if (match?.[1]) return match[1];+ } catch { /* file may not exist */ }+ }+ return undefined;+}++const isProduction = resolveEnv("NEXTJS_ENV") === "production";const nextConfig: NextConfig = {turbopack: {root: path.resolve(__dirname, "../.."),},+ env: {+ NEXT_PUBLIC_AUTH_MODE: isProduction ? "otp" : "password",+ },};export default nextConfig;diff --git a/src/web/src/app/(auth)/sign-in/page.tsx b/src/web/src/app/(auth)/sign-in/page.tsxindex fec0026ae..0221de826 100644--- a/src/web/src/app/(auth)/sign-in/page.tsx+++ b/src/web/src/app/(auth)/sign-in/page.tsx@@ -21,7 +21,7 @@ import { SiGithub, SiGoogle } from "@icons-pack/react-simple-icons"import { GradientBackground } from "@/components/gradient-background"import { TypewriterVisual } from "@/components/typewriter-visual"-const isProd = process.env.NEXTJS_ENV === "production"+const isProd = process.env.NEXT_PUBLIC_AUTH_MODE === "otp"function OTPSignIn() {const [email, setEmail] = useState("")diff --git a/src/web/src/lib/auth-client.ts b/src/web/src/lib/auth-client.tsindex 5b3f64dcc..0a36e9a8c 100644--- a/src/web/src/lib/auth-client.ts+++ b/src/web/src/lib/auth-client.ts@@ -2,11 +2,9 @@import { createAuthClient } from "better-auth/react"import { emailOTPClient } from "better-auth/client/plugins"-const isProd = process.env.NEXTJS_ENV === "production"-export const authClient = createAuthClient({baseURL: process.env.NEXT_PUBLIC_APP_URL ?? "http://localhost:3000",- plugins: isProd ? [emailOTPClient()] : [],+ plugins: [emailOTPClient()],})export const { signIn, signUp, signOut, useSession } = authClient