라벨이 AxiosError인 게시물 표시

NestJS Error https 통신중 unable to verify the first certificate 에러

 NestJS으로 POST통신중 문제가 생겼고 해결을 해서 블로그에 남깁니다. import axios from 'axios' ; import { PushBodyDto } from 'src/type/sendPushMessage.dto' ; require ( 'dotenv' ). config (); const https = require ( 'https' ); export async function sendPushMessage ( body : PushBodyDto ) { return await axios . post ( process . env . NESTJS_RESTAPI_URL + '/push-noti/send/message' , { httpsAgent : new https . Agent ({ rejectUnauthorized : false , }), data : body , }) . then (( res ) => { console . log ( '푸시메세지 보낸후 데이터 : ' , res . data ); return res . data ; }) . catch (( err ) => { return err ; }) . finally (() => console . log ( '푸시메세지 요청 완료!' )); } 코드1) 초기 Post Request 코드 위 코드에서 POST요청으로 다른서버에 Push요청을 보내는 코드 입니다. 오류 발생시 무시하는 코드(rejectUnauthorized : true)를 넣었음에도 불구하고 아래와 같이 응답이 왔습니다. 응답데이터(Click) --------------------------------------------- ...

Axios 서버에서 axios요청을 다른서버로 보낼시 에러(https)

 NestJS(NodeJS)서버에서 다른 NestJS(NodeJS)서버로 GET요청을 할때 발생된 에러 입니다.  아래는 터미널  출력 내용입니다. Axios URL :  https://goodgame:5000/users/single fetch error :  AxiosError: unable to verify the first certificate     at TLSSocket.onConnectSecure (node:_tls_wrap:1530:34)     at TLSSocket.emit (node:events:394:28)     at TLSSocket._finishInit (node:_tls_wrap:944:8)     at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:725:12) {   code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE', 위보다 훨씬 길었지만 중요한 것은 fetch error와 code입니다.  위 문제를 해결하기 위해서 axios에 코드를 추가해 줘야 합니다. const https = require ( 'https' ); const response = await axios . get ( process . env . NESTJS_RESTAPI_URL + '/users/single' , { headers : { 'Content-Type' : 'application/json' , authorization : 'Bearer ' + token , }, httpsAgent : new https . Agent ({ rejectUnauthorized : false , //허가되지 않은 인증을 reject하지 않...