http-server-proxy
Advanced tools
+12
-13
@@ -112,20 +112,19 @@ 'use strict'; | ||
| if (typeof options.proxy === 'string') { | ||
| // console.log(options.apiPrefix); | ||
| var proxy = httpProxy.createProxyServer({}); | ||
| before.push(function (req, res) { | ||
| let proxyUrl = options.proxy; | ||
| console.log(options.apiPrefix, req.url.match(options.apiPrefix)); | ||
| if(options.apiPrefix && req.url.match(options.apiPrefix) && req.headers.cookie){ | ||
| const res = /proxy_api_url=([^;]+)(;.*|$)/.exec(req.headers.cookie); | ||
| if(res && res[1]) { | ||
| // console.log(res); | ||
| proxyUrl = res[1]; | ||
| } | ||
| } | ||
| proxy.web(req, res, { | ||
| target: options.proxy, | ||
| target: proxyUrl, | ||
| changeOrigin: true, | ||
| secure: false, | ||
| router: options.apiPrefix ? function(req) { | ||
| // console.log(req); | ||
| // console.log(apiUrl); | ||
| if(req.path.match(options.apiPrefix) && req.headers.cookie){ | ||
| const res = /proxy_api_url=([^;]+)(;.*|$)/.exec(req.headers.cookie); | ||
| if(res && res[1]) { | ||
| // console.log(res); | ||
| return res[1]; | ||
| } | ||
| } | ||
| return options.proxy; | ||
| } : undefined, | ||
| }); | ||
@@ -132,0 +131,0 @@ }); |
+1
-1
| { | ||
| "name": "http-server-proxy", | ||
| "version": "0.11.1", | ||
| "version": "0.11.2", | ||
| "description": "A simple zero-configuration command-line http server", | ||
@@ -5,0 +5,0 @@ "main": "./lib/http-server", |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
15267
-0.22%133
-1.48%