mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-07-13 04:42:41 +08:00
fix: 修复 API 密钥逻辑,确保正确设置和使用 Fscan-API-SECRET 头
This commit is contained in:
parent
a30cd12249
commit
2d9ea9c1d3
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user