Revert "Auth fix"

This reverts commit 1c281c9f5d.
This commit is contained in:
Stefan Lazic committed 2026-09-05 09:32:18 +01:00
1 parent 32e93c6c23
commit c237b565bd
2 files changed
+11 -40

No files matched your search

+8 -13
View File
@@ -29,15 +29,13 @@ const INSTALL_EXEMPT_PREFIXES = [
"/sw.js",
];
// Build the business Auth.js middleware only when a business request needs
// it. Manager requests must not construct or invoke this wrapper at all.
type BusinessProxy = (req: NextRequest) => Response | Promise<Response>;
let authenticatedProxy: BusinessProxy | undefined;
function getAuthenticatedProxy() {
authenticatedProxy ??= NextAuth(authConfig).auth as unknown as BusinessProxy;
return authenticatedProxy;
}
// Lightweight instance built from the DB-free config — see auth.config.ts.
// Next.js 16 renamed this file convention from `middleware` to `proxy`
// (https://nextjs.org/docs/messages/middleware-to-proxy); it now always
// runs on the Node.js runtime rather than Edge, but this stays split from
// the full `@/auth` regardless, so checking "is there a session" doesn't
// spin up a Postgres connection pool on every request.
const { auth } = NextAuth(authConfig);
/**
* Nonce-gated 'strict-dynamic' script-src (Next's own documented pattern)
@@ -141,10 +139,7 @@ export async function handleProxyRequest(req: AuthenticatedNextRequest) {
return response;
}
export default function proxy(req: NextRequest) {
if (process.env.MANAGER_MODE === "true") return handleProxyRequest(req);
return getAuthenticatedProxy()(req);
}
export default auth(handleProxyRequest);
export const config = {
matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],