diff --git a/server/internal/api/middleware.go b/server/internal/api/middleware.go index 80dec46..50f4963 100644 --- a/server/internal/api/middleware.go +++ b/server/internal/api/middleware.go @@ -140,16 +140,10 @@ func withAuth(apiDomain string) func(http.Handler) http.Handler { // 检查认证是否成功(支持 HTTP 状态码和业务 code) if resp.StatusCode != http.StatusOK || authResp.Code != 200 { - // 优先使用业务返回的错误信息 - errorMsg := authResp.Message - if errorMsg == "" { - errorMsg = "认证失败" - } - // 返回原始的业务错误码和消息 - responseBody := fmt.Sprintf("{\"code\":%d,\"message\":\"%s\",\"data\":null}", authResp.Code, errorMsg) + // 所有认证错误都显示"请先登录" w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusUnauthorized) - w.Write([]byte(responseBody)) + w.Write([]byte("{\"code\":401,\"message\":\"请先登录\",\"data\":null}")) return }