Browse Source

fix 401 bug

Signed-off-by: nameczz <zizhao.chen@zilliz.com>
nameczz 3 years ago
parent
commit
45efe3639e

+ 1 - 1
client/src/pages/connect/Connect.tsx

@@ -76,7 +76,7 @@ const Connect = () => {
     const address = formatAddress(form.address);
     const address = formatAddress(form.address);
     await MilvusHttp.connect(address);
     await MilvusHttp.connect(address);
     openSnackBar(successTrans('connect'));
     openSnackBar(successTrans('connect'));
-    setAddress(address);
+    setAddress(form.address);
     window.localStorage.setItem(MILVUS_ADDRESS, address);
     window.localStorage.setItem(MILVUS_ADDRESS, address);
     history.push('/');
     history.push('/');
   };
   };

+ 2 - 1
client/src/utils/Format.ts

@@ -141,7 +141,8 @@ export const getCreateFieldType = (config: Field): CreateFieldType => {
 };
 };
 
 
 // Trim the address
 // Trim the address
-export const formatAddress = (address: string): string => address.trim();
+export const formatAddress = (address: string): string =>
+  address.trim().replace(/(http|https):\/\//, '');
 
 
 // generate a sting like 20.22/98.33MB with proper unit
 // generate a sting like 20.22/98.33MB with proper unit
 export const getByteString = (
 export const getByteString = (

+ 1 - 3
express/src/middlewares/index.ts

@@ -14,13 +14,11 @@ export const ReqHeaderMiddleware = (
   // all ape requests need set milvus address in header.
   // all ape requests need set milvus address in header.
   // server will set activeaddress in milvus service.
   // server will set activeaddress in milvus service.
   const milvusAddress = (req.headers[MILVUS_ADDRESS] as string) || '';
   const milvusAddress = (req.headers[MILVUS_ADDRESS] as string) || '';
-  console.log('------ Middleware req headers -------', req.headers);
-  console.log('------ Attu cache ----- ', insightCache);
+  console.log('------ Request headers -------', req.headers);
   //  only api request has MILVUS_ADDRESS.
   //  only api request has MILVUS_ADDRESS.
   //  When client run in express, we dont need static files like: xx.js run this logic.
   //  When client run in express, we dont need static files like: xx.js run this logic.
   //  Otherwise will cause 401 error.
   //  Otherwise will cause 401 error.
   if (milvusAddress && insightCache.has(milvusAddress)) {
   if (milvusAddress && insightCache.has(milvusAddress)) {
-    console.log('----- Set active address ---- ');
     MilvusService.activeAddress = milvusAddress;
     MilvusService.activeAddress = milvusAddress;
     // insight cache will update expire time when use insightCache.get
     // insight cache will update expire time when use insightCache.get
     MilvusService.activeMilvusClient = insightCache.get(
     MilvusService.activeMilvusClient = insightCache.get(

+ 0 - 1
express/src/milvus/milvus.service.ts

@@ -36,7 +36,6 @@ export class MilvusService {
   }
   }
 
 
   checkMilvus() {
   checkMilvus() {
-    console.log('---- check Milvus ----', MilvusService.activeMilvusClient);
     if (!MilvusService.activeMilvusClient) {
     if (!MilvusService.activeMilvusClient) {
       throw HttpErrors(
       throw HttpErrors(
         HTTP_STATUS_CODE.UNAUTHORIZED,
         HTTP_STATUS_CODE.UNAUTHORIZED,