feat(api): drive CORS + trusted origins from CORS_ORIGINS env
Phone/LAN testing previously required editing both app.ts (cors origin) and auth.ts (better-auth trustedOrigins). Now both read env.WEB_ORIGINS, parsed from a comma-separated CORS_ORIGINS env var (default http://localhost:5173). To test from a phone, set CORS_ORIGINS to include the LAN origin and restart the API — no code edit. Documented in .env.example. Also fixed the worker README (db:migrate creates ./data/app.db, not ./.tmp; phone step now uses CORS_ORIGINS). API tests 36/36 green; typecheck clean.
This commit is contained in:
@@ -8,7 +8,7 @@ import { env } from './env';
|
||||
export const auth = betterAuth({
|
||||
secret: env.BETTER_AUTH_SECRET,
|
||||
baseURL: env.BETTER_AUTH_URL,
|
||||
trustedOrigins: [env.BETTER_AUTH_URL, 'http://localhost:3000', 'http://localhost:5173'],
|
||||
trustedOrigins: [env.BETTER_AUTH_URL, 'http://localhost:3000', ...env.WEB_ORIGINS],
|
||||
database: drizzleAdapter(db, { provider: 'sqlite', schema }),
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
|
||||
Reference in New Issue
Block a user