1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 | exports.__esModule = true;
|
5 | exports.partytownProxy = partytownProxy;
|
6 | exports.thirdPartyProxyPath = void 0;
|
7 | var _expressHttpProxy = _interopRequireDefault(require("express-http-proxy"));
|
8 | const thirdPartyProxyPath = `/__third-party-proxy`;
|
9 | exports.thirdPartyProxyPath = thirdPartyProxyPath;
|
10 | function partytownProxy(partytownProxiedURLs) {
|
11 | return (0, _expressHttpProxy.default)(req => new URL(req.query.url).origin, {
|
12 | filter: req => partytownProxiedURLs.some(url => {
|
13 | var _req$query;
|
14 | return ((_req$query = req.query) === null || _req$query === void 0 ? void 0 : _req$query.url) === url;
|
15 | }),
|
16 | proxyReqPathResolver: req => {
|
17 | var _req$query2;
|
18 | const {
|
19 | pathname = ``,
|
20 | search = ``
|
21 | } = new URL((_req$query2 = req.query) === null || _req$query2 === void 0 ? void 0 : _req$query2.url);
|
22 | return pathname + search;
|
23 | }
|
24 | });
|
25 | }
|
26 |
|
\ | No newline at end of file |