Node-fetch: Disable SSL verification

后端 未结 3 1950
北恋
北恋 2021-02-12 15:07

I have the following code, which is run from a express server:

import fetch from \'node-fetch\';

let formBody = [];

const dataLogin = {
      \'username\': \'         


        
3条回答
  •  清酒与你
    2021-02-12 15:36

    If you want to disable SSL check while using AXIOS library, add agent to its call in this way

    // At instance level
    const instance = axios.create({
      httpsAgent: new https.Agent({  
        rejectUnauthorized: false
      })
    });
    
    instance.get('https://something.com/foo');
    
    // At request level
     const agent = new https.Agent({  
     rejectUnauthorized: false
    });
    
    axios.get('https://something.com/foo', { httpsAgent: agent });
    
    

提交回复
热议问题