Добавлен middleware для обработки авторизации, страница входа с формой и валидацией, а также стили для страницы авторизации. Обновлены зависимости js-cookie и @types/js-cookie.

This commit is contained in:
Redsandyg
2025-06-03 12:07:03 +03:00
parent 9b1cbc0300
commit 6ab1a42be7
6 changed files with 180 additions and 0 deletions

16
middleware.ts Normal file
View File

@@ -0,0 +1,16 @@
import { NextRequest, NextResponse } from 'next/server';
export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
// Получаем access_token из куков (SSR)
const token = request.cookies.get('access_token');
if (pathname === '/auth' && token) {
return NextResponse.redirect(new URL('/', request.url));
}
return NextResponse.next();
}
export const config = {
matcher: ['/auth'],
};