Files
aigen/server/middleware/auth.ts
T
TowstyandCursor 08caeb51de Eliminate xAIGen and LTX; AIGen is the only studio.
Drop the studio split, backup-to-xAIGen link, and LTX engine option. Show all LoRAs on AIGen and remove the Photos show/hide inputs toggle so slots stay visible.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-27 17:55:59 -05:00

30 lines
1021 B
TypeScript

import { aigenApiPathAllowed, aigenBearerAuthorized } from '~/server/utils/aigenApiAuth'
export default defineEventHandler((event) => {
if (!authEnabled()) return
const path = getRequestURL(event).pathname
if (
path.startsWith('/api/auth/login') ||
path.startsWith('/api/auth/callback') ||
path.startsWith('/api/auth/logout') ||
path.startsWith('/api/auth/me') ||
path.startsWith('/api/health') ||
path.startsWith('/api/monitor') ||
path.startsWith('/_nuxt') ||
path.startsWith('/favicon') ||
path === '/login'
) {
return
}
const method = String(event.method || getMethod(event) || 'GET').toUpperCase()
if (aigenApiPathAllowed(path, method) && aigenBearerAuthorized(event)) {
return
}
const user = getSessionUser(event)
if (user) return
if (path.startsWith('/api/')) {
throw createError({ statusCode: 401, statusMessage: 'Authentication required' })
}
return sendRedirect(event, path === '/studio-2' ? '/login?next=/studio-2' : '/login', 302)
})