Two bugs: 1. auth.ts imported postgres (Node.js TCP) which crashes in Edge Runtime, causing Auth.js to silently fall back to redirecting all requests to login. Fix: split into auth.config.ts (Edge-safe, no DB) used by middleware, and auth.ts (full, with DB) used by server components. 2. /agent/layout.tsx applied to /agent/login, so unauthenticated login page visits redirected to themselves in an infinite loop. Fix: moved dashboard + layout into (protected) route group so login page has no auth layout. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
10 lines
201 B
TypeScript
10 lines
201 B
TypeScript
import NextAuth from "next-auth";
|
|
import { authConfig } from "@/lib/auth.config";
|
|
|
|
const { auth } = NextAuth(authConfig);
|
|
export default auth;
|
|
|
|
export const config = {
|
|
matcher: ["/agent/:path*"],
|
|
};
|