Skip to content

Commit c647d5d

Browse files
committed
🔧 Обновлены заголовки CORS: добавлен новый заголовок X-Internal-User-Name и обновлено присвоение имени пользователя
1 parent bf94c49 commit c647d5d

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

app/cmd/cors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const getCorsHeaders = (origin: string | null): Record<string, string> =>
1010
return {
1111
"Access-Control-Allow-Origin": origin,
1212
"Access-Control-Allow-Methods": "GET, POST, PATCH, OPTIONS",
13-
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Internal-Token, X-Internal-User-Id, X-Request-Id",
13+
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Internal-Token, X-Internal-User-Id, X-Internal-User-Name, X-Request-Id",
1414
"Access-Control-Max-Age": "86400",
1515
Vary: "Origin",
1616
};

app/svc/auth/service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const validateRequest = async (req: BunRequest, _botToken: string, csotTo
4949
const isValid = validateInternalToken(internalToken, csotToken);
5050
if (isValid) {
5151
const internalUserId = req.headers.get("x-internal-user-id");
52+
const internalUserName = req.headers.get("x-internal-user-name");
5253
let user: UserProfile | undefined;
5354
if (internalUserId) {
5455
const parsed = Number.parseInt(internalUserId, 10);
@@ -58,7 +59,7 @@ export const validateRequest = async (req: BunRequest, _botToken: string, csotTo
5859

5960
user = {
6061
id: parsed,
61-
username: undefined,
62+
username: internalUserName?.trim() || undefined,
6263
first_name: undefined,
6364
last_name: undefined,
6465
photo_url: undefined,

0 commit comments

Comments
 (0)