From 5446bef3e9e5ea0c81eb65e62c7f8708c8736a3d Mon Sep 17 00:00:00 2001 From: valitovgaziz Date: Sat, 15 Nov 2025 04:51:50 +0500 Subject: [PATCH] modified: main_dc/nginx/nginx-ssl.conf modified: main_dc/yalarba/api_es/internal/router/setMiddleware.go add headers nginx --- main_dc/nginx/nginx-ssl.conf | 8 ++++++++ main_dc/yalarba/api_es/internal/router/setMiddleware.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main_dc/nginx/nginx-ssl.conf b/main_dc/nginx/nginx-ssl.conf index 854885a..34e4325 100644 --- a/main_dc/nginx/nginx-ssl.conf +++ b/main_dc/nginx/nginx-ssl.conf @@ -138,6 +138,14 @@ server { proxy_send_timeout 600; proxy_read_timeout 600; + add_header 'Access-Control-Allow-Origin' 'http://localhost:3000' always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS, PATCH' always; + add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Content-Type,X-CSRF-Token,X-Requested-With' always; + + if ($request_method = OPTIONS) { + return 204; + } # Handle preflight requests if ($request_method = OPTIONS) { return 204; diff --git a/main_dc/yalarba/api_es/internal/router/setMiddleware.go b/main_dc/yalarba/api_es/internal/router/setMiddleware.go index 7976f27..88a783b 100644 --- a/main_dc/yalarba/api_es/internal/router/setMiddleware.go +++ b/main_dc/yalarba/api_es/internal/router/setMiddleware.go @@ -30,7 +30,7 @@ func setupMiddlewares(r *chi.Mux) { r.Use(cors.Handler(cors.Options{ AllowedOrigins: []string{"https://easysite102.ru", "http://localhost:3000"}, AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"}, - AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"}, + AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token", "X-Requested-With"}, ExposedHeaders: []string{"Link"}, AllowCredentials: true, MaxAge: 300, // 5 минут