Phase 7: Frontend auth — React Router, AuthContext, Login/Register, API client
This commit is contained in:
+2
-2
@@ -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());
|
||||
|
||||
@@ -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,7 +1,7 @@
|
||||
/**
|
||||
* Ошибочный статус HTTP-ответа (подмножество используемых кодов).
|
||||
*/
|
||||
export type ApiErrorCode = 400 | 401 | 403 | 404 | 409 | 500;
|
||||
export type ApiErrorCode = 400 | 401 | 403 | 404 | 409 | 413 | 500;
|
||||
|
||||
/**
|
||||
* Ожидаемая (предусмотренная) ошибка приложения.
|
||||
|
||||
Reference in New Issue
Block a user