Files
Nexumi/apps/webui/src/middleware.ts
smueller 8a8aefb4fb Implement Owner Panel features and maintenance mode handling
- Introduced the Owner Panel with new routes and UI components for managing guilds, user blacklists, feature flags, and bot presence.
- Added maintenance mode functionality to prevent non-owner users from executing commands during maintenance periods.
- Enhanced localization with new keys for Owner Panel features in both English and German.
- Updated job processing to include a presence refresh job, ensuring the bot's status is regularly updated.
- Improved environment configuration to support owner user IDs for access control.
2026-07-22 16:10:30 +02:00

29 lines
1002 B
TypeScript

import { NextResponse, type NextRequest } from 'next/server';
// Kept as a literal (not imported from `lib/session.ts`) on purpose: the
// Edge middleware runtime cannot bundle the Redis/Node-only code that
// `lib/session.ts` pulls in, so this file must stay dependency-free.
const SESSION_COOKIE_NAME = 'nexumi_session';
/**
* Lightweight edge-safe guard: only checks that the session cookie exists.
* The actual session and permission validation happens in
* `requireAuthOrRedirect` / `requireGuildAccessOrRedirect` inside the
* dashboard layouts, since that requires Redis/Prisma access which is not
* available in the middleware runtime.
*/
export function middleware(request: NextRequest) {
const hasSession = request.cookies.has(SESSION_COOKIE_NAME);
if (!hasSession) {
const loginUrl = new URL('/login', request.url);
return NextResponse.redirect(loginUrl);
}
return NextResponse.next();
}
export const config = {
matcher: ['/dashboard/:path*', '/owner/:path*']
};