https-proxy-agent 在我的节点项目中不起作用

问题描述 投票:0回答:1

这是一个非常小的应用程序,我试图通过它从 s3 存储桶下载文件,并在公司代理配置后面运行它。我正在使用“https-proxy-agent”在 api 调用中设置代理,但当我尝试启动节点应用程序时,应用程序给出错误。 我尝试了一些其他方法来使用 proxyagent 但没有成功。

出现以下错误。
代理:新的ProxyAgent(proxyUrl)。
^ 类型错误:ProxyAgent 不是构造函数

下面是我的代码

const AWS = require('aws-sdk');
const fs = require('fs');
const path = require('path');
const ProxyAgent = require('https-proxy-agent')

const app = express();
const port = 3003;
const proxyUrl = 'http://pac.prod.proxy.cargill.com:4200/proxy.pac'

// Set your AWS credentials and region
AWS.config.update({
    secretAccessKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    accessKeyId: 'xxxxxxxxxxxxxxxxxxxx',
    region: 'us-east-1',
    httpOptions:{
      agent: new ProxyAgent(proxyUrl)
    }
});

// Initialize S3
const s3 = new AWS.S3();```


node.js amazon-s3 aws-sdk https-proxy-agent
1个回答
0
投票

模块的文档说将其导入为

import { HttpsProxyAgent } from 'https-proxy-agent';

,即不是默认导出。

这将转化为

const { HttpsProxyAgent } = require('https-proxy-agent');
© www.soinside.com 2019 - 2024. All rights reserved.