From 2d9ea9c1d38620db33199b9105b9fe2ac7085d04 Mon Sep 17 00:00:00 2001 From: tongque <2863528786@qq.com> Date: Tue, 22 Apr 2025 13:01:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20API=20=E5=AF=86?= =?UTF-8?q?=E9=92=A5=E9=80=BB=E8=BE=91=EF=BC=8C=E7=A1=AE=E4=BF=9D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E8=AE=BE=E7=BD=AE=E5=92=8C=E4=BD=BF=E7=94=A8=20Fscan-?= =?UTF-8?q?API-SECRET=20=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RPC/server.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RPC/server.go b/RPC/server.go index f6b43f3..bfd9cf8 100644 --- a/RPC/server.go +++ b/RPC/server.go @@ -21,7 +21,9 @@ func StartApiServer() error { if Common.ApiAddr == "" { return nil } - if Common.SecretKey == "" { + if Common.SecretKey != "" { + internalSecretKey = Common.SecretKey + } else { internalSecretKey = time.Now().Format("20060102150405") } @@ -77,7 +79,7 @@ func applyMiddlewares(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS") - w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization") + w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization, Fscan-API-SECRET") if r.Method == "OPTIONS" { w.WriteHeader(http.StatusOK)