5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Proxy管理下でaxiosを使う場合のメモ

Posted at

毎度ググるのでメモ
proxyをfalseにして、agentにhttps-proxy-agent経由で渡した値を持たせる。

サンプル

import "dotenv/config";
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";

export const axiosSample = async () => {
  const url = "https://example.com";
  const proxyServer = process.env.PROXY_URL;
  const agent = new HttpsProxyAgent(proxyServer);
  const res = await axios({
    method: "GET",
    url,
    httpsAgent: agent,
    proxy: false,
  }).catch((e) => {
    console.error(e.message);
    throw e
  });
  console.log(res.data);
}
5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?