grunt-connect-proxy
Advanced tools
Comparing version 0.1.11 to 0.2.0
@@ -121,2 +121,8 @@ /* | ||
} | ||
}, | ||
{ | ||
context: '/hideHeaders', | ||
host: 'localhost', | ||
port: 8081, | ||
hideHeaders: ['x-hidden-header-1', 'x-hidden-header-2'] | ||
} | ||
@@ -133,3 +139,4 @@ ] | ||
utils: 'test/utils_test.js', | ||
request: 'test/request_test.js' | ||
request: 'test/request_test.js', | ||
hideHeaders: 'test/hide_headers_test.js' | ||
} | ||
@@ -161,3 +168,4 @@ | ||
'connect:request', | ||
'nodeunit:request' | ||
'nodeunit:request', | ||
'nodeunit:hideHeaders' | ||
]); | ||
@@ -164,0 +172,0 @@ |
@@ -107,2 +107,17 @@ 'use strict'; | ||
function removeHiddenHeaders(proxy) { | ||
var hiddenHeaders = proxy.config.hideHeaders; | ||
if(hiddenHeaders && hiddenHeaders.length > 0) { | ||
proxy.server.on('proxyRes', function(proxyRes) { | ||
var headers = proxyRes.headers; | ||
hiddenHeaders.forEach(function(header) { | ||
if(header in headers) { | ||
delete headers[header]; | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
utils.proxyRequest = function (req, res, next) { | ||
@@ -124,3 +139,6 @@ var proxied = false; | ||
} | ||
proxy.server.proxyRequest(req, res); | ||
proxy.server.proxyRequest(req, res, proxy.server); | ||
removeHiddenHeaders(proxy); | ||
// proxying twice would cause the writing to a response header that is already sent. Bad config! | ||
@@ -127,0 +145,0 @@ proxied = true; |
{ | ||
"name": "grunt-connect-proxy", | ||
"description": "Provides a http proxy as middleware for grunt connect.", | ||
"version": "0.1.11", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/drewzboto/grunt-connect-proxy", | ||
@@ -31,3 +31,3 @@ "author": { | ||
"dependencies": { | ||
"http-proxy": "~1.1.4", | ||
"http-proxy": "~1.11.0", | ||
"lodash": "~0.9.0" | ||
@@ -34,0 +34,0 @@ }, |
@@ -44,3 +44,4 @@ # grunt-connect-proxy | ||
"x-custom-added-header": value | ||
} | ||
}, | ||
hideHeaders: ['x-removed-header'] | ||
} | ||
@@ -198,2 +199,7 @@ ] | ||
#### options.hideHeaders | ||
Type: `Array` | ||
An array of headers that should be removed from the server's response. | ||
#### options.ws | ||
@@ -200,0 +206,0 @@ Type: `Boolean` |
@@ -56,2 +56,4 @@ /* | ||
xfwd: proxyOption.xforward | ||
}).on('error', function (err, req, res) { | ||
grunt.log.error('Proxy error: ', err.code); | ||
}), | ||
@@ -58,0 +60,0 @@ config: proxyOption |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
40867
16
860
267
5
+ Addedeventemitter3@1.2.0(transitive)
+ Addedhttp-proxy@1.11.3(transitive)
+ Addedrequires-port@0.0.1(transitive)
- Removedeventemitter3@5.0.1(transitive)
- Removedhttp-proxy@1.1.6(transitive)
Updatedhttp-proxy@~1.11.0