UNPKG

@pact-foundation/pact

Version:
23 lines 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toServerOptions = void 0; const node_stream_1 = require("node:stream"); const https_proxy_agent_1 = require("https-proxy-agent"); const parseBody_1 = require("./parseBody"); // A base URL is always needed for the proxy, even // if there are no targets to proxy (e.g. in the case // of message pact const defaultBaseURL = () => 'http://127.0.0.1/'; const toServerOptions = (config, req) => { // Provide direct support for standard proxy configuration const systemProxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY; return { changeOrigin: config.changeOrigin === true, secure: config.validateSSL === true, target: config.providerBaseUrl || defaultBaseURL(), agent: systemProxy && new https_proxy_agent_1.HttpsProxyAgent(systemProxy), buffer: node_stream_1.Readable.from((0, parseBody_1.parseBody)(req)), }; }; exports.toServerOptions = toServerOptions; //# sourceMappingURL=proxyRequest.js.map