From 5e1021a18e0280e34e36f7a23c4837ca370a0281 Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 24 Dec 2024 14:22:49 +0300 Subject: [PATCH] corsfix-34 --- nginx.conf.sigil | 6 +++++- services/auth.py | 10 +++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index 4feb651c..c5173cd4 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -6,7 +6,11 @@ {{ $cors_headers_get := "if ($request_method = 'GET') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'POST, GET, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always; add_header 'Access-Control-Allow-Credentials' 'true' always; }" }} map $http_origin $allow_origin { - ~^https?:\/\/((.*\.)?localhost(:\d+)?|discoursio-webapp(-(.*))?\.vercel\.app|(.*\.)?discours\.io|(.*\.)?dscrs\.site)$ $http_origin; + ~^https?:\/\/(.*\.)?localhost(:\d+)?$ $http_origin; + ~^https?:\/\/(.*\.)?discours\.io$ $http_origin; + ~^https?:\/\/(.*\.)?dscrs\.site$ $http_origin; + ~^https?:\/\/testing\.(discours\.io|dscrs\.site)$ $http_origin; + ~^https?:\/\/discoursio-webapp(-.*)?\.vercel\.app$ $http_origin; default ""; } diff --git a/services/auth.py b/services/auth.py index 676e31c9..4a56a2c1 100644 --- a/services/auth.py +++ b/services/auth.py @@ -45,13 +45,9 @@ async def check_auth(req): operation = "ValidateToken" variables = {"params": {"token_type": "access_token", "token": token}} - # Добавляем CORS заголовки + # Только необходимые заголовки для GraphQL запроса headers = { - 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', - 'Access-Control-Allow-Headers': ', '.join(ALLOWED_HEADERS), - 'Access-Control-Allow-Credentials': 'true' + 'Content-Type': 'application/json' } gql = { @@ -114,7 +110,7 @@ def login_required(f): """ Декоратор для проверки авторизации пользователя. - Этот декоратор проверяет, авторизован ли пользователь, и добавляет + Этот декоратор проверяет, авторизован ли пользователь, �� добавляет информацию о пользователе в контекст функции. Параметры: