http-proxy-middleware 0.17.2 → 0.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.17.3](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.17.3)
4
+ - fix(onError): improve default proxy error handling. http status codes (504, 502 and 500). ([#132](https://github.com/chimurai/http-proxy-middleware/pull/132)) ([graingert](https://github.com/graingert))
5
+
3
6
  ## [v0.17.2](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.17.2)
4
7
  - feat(logging): improve error message & add link to Node errors page. ([#106](https://github.com/chimurai/http-proxy-middleware/pull/106)) ([cloudmu](https://github.com/cloudmu))
5
8
  - feat(pathRewrite): path can be empty string. ([#110](https://github.com/chimurai/http-proxy-middleware/pull/110)) ([sunnylqm](https://github.com/sunnylqm))
package/README.md CHANGED
@@ -107,8 +107,8 @@ var options = {
107
107
  changeOrigin: true, // needed for virtual hosted sites
108
108
  ws: true, // proxy websockets
109
109
  pathRewrite: {
110
- '^/old/api' : '/new/api', // rewrite path
111
- '^/remove/api' : '/api' // remove path
110
+ '^/api/old-path' : '/api/new-path', // rewrite path
111
+ '^/api/remove/path' : '/path' // remove base path
112
112
  },
113
113
  router: {
114
114
  // when request.headers.host == 'dev.localhost:3000',
@@ -304,15 +304,29 @@ The following options are provided by the underlying [http-proxy](https://github
304
304
  * **option.xfwd**: true/false, adds x-forward headers
305
305
  * **option.secure**: true/false, if you want to verify the SSL Certs
306
306
  * **option.toProxy**: true/false, passes the absolute URL as the `path` (useful for proxying to proxies)
307
- * **option.prependPath**: true/false, Default: true - specify whether you want to prepend the target's path to the proxy path>
308
- * **option.ignorePath**: true/false, Default: false - specify whether you want to ignore the proxy path of the incoming request>
307
+ * **option.prependPath**: true/false, Default: true - specify whether you want to prepend the target's path to the proxy path
308
+ * **option.ignorePath**: true/false, Default: false - specify whether you want to ignore the proxy path of the incoming request (note: you will have to append / manually if required).
309
309
  * **option.localAddress** : Local interface string to bind for outgoing connections
310
- * **option.changeOrigin**: true/false, adds host to request header.
310
+ * **option.changeOrigin**: true/false, Default: false - changes the origin of the host header to the target URL
311
311
  * **option.auth** : Basic authentication i.e. 'user:password' to compute an Authorization header.
312
312
  * **option.hostRewrite**: rewrites the location hostname on (301/302/307/308) redirects.
313
313
  * **option.autoRewrite**: rewrites the location host/port on (301/302/307/308) redirects based on requested host/port. Default: false.
314
314
  * **option.protocolRewrite**: rewrites the location protocol on (301/302/307/308) redirects to 'http' or 'https'. Default: null.
315
+ * **option.cookieDomainRewrite**: rewrites domain of `set-cookie` headers. Possible values:
316
+ * `false` (default): disable cookie rewriting
317
+ * String: new domain, for example `cookieDomainRewrite: "new.domain"`. To remove the domain, use `cookieDomainRewrite: ""`.
318
+ * Object: mapping of domains to new domains, use `"*"` to match all domains.
319
+ For example keep one domain unchanged, rewrite one domain and remove other domains:
320
+ ```
321
+ cookieDomainRewrite: {
322
+ "unchanged.domain": "unchanged.domain",
323
+ "old.domain": "new.domain",
324
+ "*": ""
325
+ }
326
+ ```
315
327
  * **option.headers**: object, adds [request headers](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields). (Example: `{host:'www.example.org'}`)
328
+ * **option.proxyTimeout**: timeout (in millis) when proxy receives no response from target
329
+
316
330
 
317
331
 
318
332
  ## Shorthand
package/lib/handlers.js CHANGED
@@ -48,9 +48,21 @@ function getProxyEventHandlers(opts) {
48
48
 
49
49
  function defaultErrorHandler(err, req, res) {
50
50
  var host = (req.headers && req.headers.host);
51
+ var code = err.code;
51
52
 
52
53
  if (res.writeHead && !res.headersSent) {
53
- res.writeHead(500);
54
+ if (/HPE_INVALID/.test(code)) {
55
+ res.writeHead(502);
56
+ } else {
57
+ switch(code) {
58
+ case 'ECONNRESET':
59
+ case 'ENOTFOUND':
60
+ case 'ECONNREFUSED':
61
+ res.writeHead(504);
62
+ break;
63
+ default: res.writeHead(500);
64
+ }
65
+ }
54
66
  }
55
67
 
56
68
  res.end('Error occured while trying to proxy to: ' + host + req.url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "http-proxy-middleware",
3
- "version": "0.17.2",
3
+ "version": "0.17.3",
4
4
  "description": "The one-liner node.js proxy middleware for connect, express and browser-sync",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -39,22 +39,22 @@
39
39
  },
40
40
  "homepage": "https://github.com/chimurai/http-proxy-middleware",
41
41
  "devDependencies": {
42
- "browser-sync": "^2.14.0",
42
+ "browser-sync": "^2.18.2",
43
43
  "chai": "^3.5.0",
44
- "connect": "^3.4.1",
45
- "coveralls": "^2.11.12",
44
+ "connect": "^3.5.0",
45
+ "coveralls": "^2.11.15",
46
46
  "express": "^4.14.0",
47
- "istanbul": "^0.4.4",
47
+ "istanbul": "^0.4.5",
48
48
  "istanbul-coveralls": "^1.0.3",
49
- "mocha": "^3.0.2",
49
+ "mocha": "^3.2.0",
50
50
  "mocha-lcov-reporter": "1.2.0",
51
51
  "opn": "^4.0.2",
52
52
  "ws": "^1.1.1"
53
53
  },
54
54
  "dependencies": {
55
- "http-proxy": "^1.15.1",
56
- "is-glob": "^3.0.0",
57
- "lodash": "^4.16.2",
55
+ "http-proxy": "^1.16.2",
56
+ "is-glob": "^3.1.0",
57
+ "lodash": "^4.17.2",
58
58
  "micromatch": "^2.3.11"
59
59
  }
60
60
  }