Node.js global proxy setting

前端 未结 5 2261
孤城傲影
孤城傲影 2020-12-12 16:58

I was working in a corporate network behind a proxy server. In my code I can set the proxy by using the approach mentioned in this thread.

But the problem is that mo

5条回答
  •  甜味超标
    2020-12-12 17:33

    You can try my package node-global-proxy which work with all node versions and most of http-client (axios, got, superagent, request etc.)

    after install by

    npm install node-global-proxy --save

    a global proxy can start by

    const proxy = require("node-global-proxy").default;
    
    proxy.setConfig({
      http: "http://localhost:1080",
      https: "https://localhost:1080",
    });
    proxy.start();
    
    /** Proxy working now! */
    
    

    More information available here: https://github.com/wwwzbwcom/node-global-proxy

提交回复
热议问题