Phase 7: Frontend auth — React Router, AuthContext, Login/Register, API client

This commit is contained in:
Suslov-MD
2026-08-16 08:54:31 +00:00
parent 281daa4717
commit ac85d71c65
16 changed files with 578 additions and 3 deletions
+2 -2
View File
@@ -27,8 +27,8 @@ export function createApp(extraMiddleware?: express.RequestHandler): express.Exp
// Security headers
app.use(helmet());
// CORS — whitelist из CLIENT_ORIGIN
app.use(cors({ origin: env.clientOrigin }));
// CORS — whitelist из CLIENT_ORIGIN (поддерживается несколько через запятую)
app.use(cors({ origin: env.clientOrigins }));
// Парсинг тела запроса
app.use(json());
+2
View File
@@ -36,6 +36,7 @@ export interface Env {
readonly jwtSecret: string;
readonly jwtExpiresIn: string;
readonly clientOrigin: string;
readonly clientOrigins: string[];
readonly uploadDir: string;
readonly maxUploadSize: number;
readonly schedulerIntervalMs: number;
@@ -105,6 +106,7 @@ export function loadEnv(): Env {
jwtSecret: required('JWT_SECRET'),
jwtExpiresIn: process.env.JWT_EXPIRES_IN ?? '7d',
clientOrigin: process.env.CLIENT_ORIGIN ?? 'http://localhost:5173',
clientOrigins: (process.env.CLIENT_ORIGIN ?? 'http://localhost:5173').split(',').map((s) => s.trim()),
uploadDir,
maxUploadSize: parseMaxUploadSize(process.env.MAX_UPLOAD_SIZE ?? String(20 * 1024 * 1024)),
schedulerIntervalMs: Number.parseInt(process.env.SCHEDULER_INTERVAL_MS ?? '20000', 10),
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* Ошибочный статус HTTP-ответа (подмножество используемых кодов).
*/
export type ApiErrorCode = 400 | 401 | 403 | 404 | 409 | 500;
export type ApiErrorCode = 400 | 401 | 403 | 404 | 409 | 413 | 500;
/**
* Ожидаемая (предусмотренная) ошибка приложения.