axiosで「unable to verify the first certificate」エラーを無視する
curlコマンドで「unable to verify the first certificate」エラーが出た場合は-kオプションで無視できますが、axiosで無視する場合は、httpsAgentオプションを指定します。
import axios from 'axios' import https from 'https' // 追加 const options = { method: 'POST', headers: { 'content-type': 'application/x-www-form-urlencoded' }, data: qs.stringify(jsondata), url: 'https://~~~', httpsAgent: new https.Agent({ rejectUnauthorized: false }) // 追加 } const results= await axios(options).catch(error => { // error logic })
これでhttpsで始まるURLで出てくる「unable to verify the first certificate」エラーを無視することができます。
参考サイト
How to ignore SSL issues · Issue #535 · axios/axios
Is it possible to configure Axios (running in node.js) to ignore specific SSL errors (like expired certificates)? I'd like to know that the SSL certificate has ...
curlコマンドで「unable to verify the first certificate」エラーを無視する

KHI入社して退社。今はCONFRAGEで正社員です。関西で140-170/80~120万から受け付けております^^
得意技はJS(ES6),Java,AWSの大体のリソースです
コメントはやさしくお願いいたします^^
座右の銘は、「狭き門より入れ」「願わくは、我に七難八苦を与えたまえ」です^^
資格:少額短期保険募集人,FP3級,宅建士
コメント