fix(auth): skip resolveStaffMiddleware on Better-Auth routes
resolveStaffMiddleware crashed with "Cannot read properties of undefined (reading 'sub')" on /api/auth/* requests because authMiddleware skips those paths without setting jwtPayload. Add the same skip so Better-Auth routes pass through cleanly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,12 @@ export const resolveStaffMiddleware: MiddlewareHandler<AppEnv> = async (
|
|||||||
c,
|
c,
|
||||||
next
|
next
|
||||||
) => {
|
) => {
|
||||||
|
// Better-Auth's own routes handle their own auth — skip staff resolution
|
||||||
|
if (c.req.path.startsWith("/api/auth/")) {
|
||||||
|
await next();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const db = getDb();
|
const db = getDb();
|
||||||
|
|
||||||
if (process.env.AUTH_DISABLED === "true") {
|
if (process.env.AUTH_DISABLED === "true") {
|
||||||
|
|||||||
Reference in New Issue
Block a user