nuxt axios https error unable to verify the first certificate

在~/plugins/axios.js 中,按如下修改

import https from 'https';

export default function ({ $axios, store }) {
    const agent = new https.Agent({  
        rejectUnauthorized: false
    }); 

    $axios.onRequest(config => {
        if (process.env.NODE_ENV === 'development') { // 此处,视个人情况而定
            config.httpsAgent = agent;
        }                     
    });
}

ok,打道回府。

你可能感兴趣的:(nuxt axios https error unable to verify the first certificate)