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
refactor(web): replace NEXTJS_ENV with AUTH_MODE for auth branching
Generab7256c1f259
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 39f7d2cd3..2c15b39c9 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -48,7 +48,6 @@ jobs:env:BETTER_AUTH_SECRET: ci-e2e-secretBETTER_AUTH_URL: http://localhost:3000- NEXTJS_ENV: developmentsteps:- uses: actions/checkout@v6- uses: pnpm/action-setup@v6@@ -59,7 +58,7 @@ jobs:cache: pnpm- run: pnpm install --frozen-lockfile- name: Create .dev.vars for local bindings- run: printf 'BETTER_AUTH_SECRET=ci-e2e-secret\nBETTER_AUTH_URL=http://localhost:3000\nNEXTJS_ENV=development\n' > src/web/.dev.vars+ run: printf 'BETTER_AUTH_SECRET=ci-e2e-secret\nBETTER_AUTH_URL=http://localhost:3000\nAUTH_MODE=password\n' > src/web/.dev.vars- run: pnpm run db:migrate- name: Start dev serverrun: |diff --git a/src/web/.dev.vars.example b/src/web/.dev.vars.exampleindex 305d978a8..bc773a9ae 100644--- a/src/web/.dev.vars.example+++ b/src/web/.dev.vars.example@@ -18,6 +18,6 @@ GITHUB_CLIENT_SECRET=GOOGLE_CLIENT_ID=GOOGLE_CLIENT_SECRET=-# Override wrangler.toml's NEXTJS_ENV=production for local dev-# This enables password auth and disables email OTP locally-NEXTJS_ENV=development+# Override wrangler.toml's AUTH_MODE=otp for local dev+# "password" enables email+password auth, "otp" enables email OTP+AUTH_MODE=passworddiff --git a/src/web/cloudflare-env.d.ts b/src/web/cloudflare-env.d.tsindex 80e033a1a..e9f37d8ef 100644--- a/src/web/cloudflare-env.d.ts+++ b/src/web/cloudflare-env.d.ts@@ -5,7 +5,7 @@ declare namespace Cloudflare {interface Env {IMAGES: ImagesBinding;ASSETS: Fetcher;- NEXTJS_ENV: string;+ AUTH_MODE: string;WORKER_SELF_REFERENCE: Fetcher /* web */;}}@@ -14,7 +14,7 @@ type StringifyValues<EnvType extends Record<string, unknown>> = {[Binding in keyof EnvType]: EnvType[Binding] extends string ? EnvType[Binding] : string;};declare namespace NodeJS {- interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "NEXTJS_ENV">> {}+ interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "AUTH_MODE">> {}}// Begin runtime typesdiff --git a/src/web/next.config.ts b/src/web/next.config.tsindex 18bd497a0..abf57a701 100644--- a/src/web/next.config.ts+++ b/src/web/next.config.ts@@ -2,15 +2,13 @@ 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,+// Resolve AUTH_MODE 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 {+function resolveVar(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 content = readFileSync(path.resolve(__dirname, 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 */ }@@ -18,14 +16,12 @@ function resolveEnv(key: string): string | undefined {return undefined;}-const isProduction = resolveEnv("NEXTJS_ENV") === "production";-const nextConfig: NextConfig = {turbopack: {root: path.resolve(__dirname, "../.."),},env: {- NEXT_PUBLIC_AUTH_MODE: isProduction ? "otp" : "password",+ NEXT_PUBLIC_AUTH_MODE: resolveVar("AUTH_MODE") ?? "password",},};diff --git a/src/web/src/lib/auth.ts b/src/web/src/lib/auth.tsindex 4423e41a9..a0e9462dd 100644--- a/src/web/src/lib/auth.ts+++ b/src/web/src/lib/auth.ts@@ -2,7 +2,7 @@ import { betterAuth } from "better-auth"import { emailOTP } from "better-auth/plugins"import { getOtpSubject, renderOtpEmail } from "./email-templates"-const isProduction = (env: Env) => env.NEXTJS_ENV === "production"+const isOtp = (env: Env) => env.AUTH_MODE === "otp"export function createAuth(env: Env) {return betterAuth({@@ -10,7 +10,7 @@ export function createAuth(env: Env) {database: env.DB,secret: env.BETTER_AUTH_SECRET,emailAndPassword: {- enabled: !isProduction(env),+ enabled: !isOtp(env),requireEmailVerification: false,},socialProviders: {@@ -23,7 +23,7 @@ export function createAuth(env: Env) {clientSecret: env.GOOGLE_CLIENT_SECRET,},},- plugins: isProduction(env)+ plugins: isOtp(env)? [emailOTP({async sendVerificationOTP({ email, otp, type }) {diff --git a/src/web/wrangler.toml b/src/web/wrangler.tomlindex cbc5d0b8d..7f0514860 100644--- a/src/web/wrangler.toml+++ b/src/web/wrangler.toml@@ -4,7 +4,7 @@ compatibility_date = "2026-04-09"compatibility_flags = ["nodejs_compat"][vars]-NEXTJS_ENV = "production"+AUTH_MODE = "otp"# OpenNext required bindings[assets]