프록시 구성(Node.js)
노드 SDK의 HTTP 요청에 대한 프록시를 구성하려면 초기화하는 동안 SDK에서 사용한 가져오기 API를 재정의합니다.
다음은 프록시를 추가하기 위해 TargetClient을(를) 초기화하는 동안 fetchApi을(를) 재정의하는 방법을 보여주는 기본 예입니다.
const { ProxyAgent } = require("undici");
const proxyAgent = new ProxyAgent("your proxy address here");
const fetchImpl = (url, options) => {
const fetchOptions = options;
fetchOptions.dispatcher = proxyAgent;
return fetch(url, fetchOptions);
};
client = TargetClient.create({
...,
fetchApi: fetchImpl
});
이 기능은 노드 버전 18.2+에서만 작동하며, 여기서 undici.fetch은(는) 노드의 기본 fetch입니다.
노드 SDK 샘플 저장소를 방문하십시오.
프록시 구성 예제를 참조하십시오.
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3