Browse Source

fix: 403 issue (#761)

* fix: 403 issue

Signed-off-by: ryjiang <jiangruiyi@gmail.com>

* update

Signed-off-by: ryjiang <jiangruiyi@gmail.com>

---------

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 4 months ago
parent
commit
3c0166a45e
1 changed files with 6 additions and 5 deletions
  1. 6 5
      server/src/middleware/index.ts

+ 6 - 5
server/src/middleware/index.ts

@@ -32,17 +32,18 @@ export const ReqHeaderMiddleware = (
   }
 
   const bypassURLs = [`/api/v1/milvus/connect`, `/api/v1/milvus/version`];
-  const bypass = bypassURLs.indexOf(req.url) !== -1;
-  const hasClient = clientCache.get(milvusClientId);
 
-  if (!bypass && !hasClient) {
+  if (
+    bypassURLs.indexOf(req.url) === -1 &&
+    milvusClientId &&
+    !clientCache.get(milvusClientId)
+  ) {
     throw HttpErrors(
       HTTP_STATUS_CODE.UNAUTHORIZED,
       'Can not find your connection, please reconnect.'
     );
-  } else {
-    next();
   }
+  next();
 };
 
 export const TransformResMiddleware = (