http-proxy-middleware 2.0.3 → 2.0.6
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/README.md +5 -9
- package/dist/_handlers.js +10 -0
- package/dist/handlers/fix-request-body.js +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -9,14 +9,14 @@ Node.js proxying made simple. Configure proxy middleware with ease for [connect]
|
|
|
9
9
|
|
|
10
10
|
Powered by the popular Nodejitsu [`http-proxy`](https://github.com/nodejitsu/node-http-proxy). [](https://github.com/nodejitsu/node-http-proxy)
|
|
11
11
|
|
|
12
|
-
## ⚠️ Note
|
|
12
|
+
## ⚠️ Note <!-- omit in toc -->
|
|
13
13
|
|
|
14
|
-
This page is showing documentation for version
|
|
14
|
+
This page is showing documentation for version v2.x.x ([release notes](https://github.com/chimurai/http-proxy-middleware/releases))
|
|
15
15
|
|
|
16
16
|
If you're looking for v0.x documentation. Go to:
|
|
17
17
|
https://github.com/chimurai/http-proxy-middleware/tree/v0.21.0#readme
|
|
18
18
|
|
|
19
|
-
## TL;DR
|
|
19
|
+
## TL;DR <!-- omit in toc -->
|
|
20
20
|
|
|
21
21
|
Proxy `/api` requests to `http://www.example.org`
|
|
22
22
|
|
|
@@ -52,9 +52,7 @@ _All_ `http-proxy` [options](https://github.com/nodejitsu/node-http-proxy#option
|
|
|
52
52
|
|
|
53
53
|
:bulb: **Tip:** Set the option `changeOrigin` to `true` for [name-based virtual hosted sites](http://en.wikipedia.org/wiki/Virtual_hosting#Name-based).
|
|
54
54
|
|
|
55
|
-
## Table of Contents
|
|
56
|
-
|
|
57
|
-
<!-- MarkdownTOC autolink=true bracket=round depth=2 -->
|
|
55
|
+
## Table of Contents <!-- omit in toc -->
|
|
58
56
|
|
|
59
57
|
- [Install](#install)
|
|
60
58
|
- [Core concept](#core-concept)
|
|
@@ -65,7 +63,7 @@ _All_ `http-proxy` [options](https://github.com/nodejitsu/node-http-proxy#option
|
|
|
65
63
|
- [http-proxy events](#http-proxy-events)
|
|
66
64
|
- [http-proxy options](#http-proxy-options)
|
|
67
65
|
- [Shorthand](#shorthand)
|
|
68
|
-
- [app.use
|
|
66
|
+
- [app.use(path, proxy)](#appusepath-proxy)
|
|
69
67
|
- [WebSocket](#websocket)
|
|
70
68
|
- [External WebSocket upgrade](#external-websocket-upgrade)
|
|
71
69
|
- [Intercept and manipulate requests](#intercept-and-manipulate-requests)
|
|
@@ -77,8 +75,6 @@ _All_ `http-proxy` [options](https://github.com/nodejitsu/node-http-proxy#option
|
|
|
77
75
|
- [Changelog](#changelog)
|
|
78
76
|
- [License](#license)
|
|
79
77
|
|
|
80
|
-
<!-- /MarkdownTOC -->
|
|
81
|
-
|
|
82
78
|
## Install
|
|
83
79
|
|
|
84
80
|
```bash
|
package/dist/_handlers.js
CHANGED
|
@@ -8,6 +8,16 @@ function init(proxy, option) {
|
|
|
8
8
|
for (const eventName of Object.keys(handlers)) {
|
|
9
9
|
proxy.on(eventName, handlers[eventName]);
|
|
10
10
|
}
|
|
11
|
+
// https://github.com/webpack/webpack-dev-server/issues/1642
|
|
12
|
+
proxy.on('econnreset', (error, req, res, target) => {
|
|
13
|
+
logger.error(`[HPM] ECONNRESET: %O`, error);
|
|
14
|
+
});
|
|
15
|
+
// https://github.com/webpack/webpack-dev-server/issues/1642#issuecomment-1104325120
|
|
16
|
+
proxy.on('proxyReqWs', (proxyReq, req, socket, options, head) => {
|
|
17
|
+
socket.on('error', (error) => {
|
|
18
|
+
logger.error(`[HPM] WebSocket error: %O`, error);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
11
21
|
logger.debug('[HPM] Subscribed to http-proxy events:', Object.keys(handlers));
|
|
12
22
|
}
|
|
13
23
|
exports.init = init;
|
|
@@ -19,7 +19,7 @@ function fixRequestBody(proxyReq, req) {
|
|
|
19
19
|
if (contentType && contentType.includes('application/json')) {
|
|
20
20
|
writeBody(JSON.stringify(requestBody));
|
|
21
21
|
}
|
|
22
|
-
if (contentType
|
|
22
|
+
if (contentType && contentType.includes('application/x-www-form-urlencoded')) {
|
|
23
23
|
writeBody(querystring.stringify(requestBody));
|
|
24
24
|
}
|
|
25
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "http-proxy-middleware",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "The one-liner node.js proxy middleware for connect, express and browser-sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -53,35 +53,35 @@
|
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://github.com/chimurai/http-proxy-middleware#readme",
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@commitlint/cli": "16.1
|
|
57
|
-
"@commitlint/config-conventional": "16.
|
|
56
|
+
"@commitlint/cli": "16.2.1",
|
|
57
|
+
"@commitlint/config-conventional": "16.2.1",
|
|
58
58
|
"@types/express": "4.17.13",
|
|
59
59
|
"@types/is-glob": "4.0.2",
|
|
60
60
|
"@types/jest": "27.4.0",
|
|
61
61
|
"@types/micromatch": "4.0.2",
|
|
62
|
-
"@types/node": "17.0.
|
|
62
|
+
"@types/node": "17.0.18",
|
|
63
63
|
"@types/supertest": "2.0.11",
|
|
64
64
|
"@types/ws": "8.2.2",
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
66
|
-
"@typescript-eslint/parser": "5.
|
|
67
|
-
"body-parser": "1.19.
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "5.12.0",
|
|
66
|
+
"@typescript-eslint/parser": "5.12.0",
|
|
67
|
+
"body-parser": "1.19.2",
|
|
68
68
|
"browser-sync": "2.27.7",
|
|
69
69
|
"connect": "3.7.0",
|
|
70
|
-
"eslint": "8.
|
|
70
|
+
"eslint": "8.9.0",
|
|
71
71
|
"eslint-config-prettier": "8.3.0",
|
|
72
72
|
"eslint-plugin-prettier": "4.0.0",
|
|
73
|
-
"express": "4.17.
|
|
73
|
+
"express": "4.17.3",
|
|
74
74
|
"get-port": "5.1.1",
|
|
75
75
|
"husky": "7.0.4",
|
|
76
|
-
"jest": "27.
|
|
77
|
-
"lint-staged": "12.
|
|
78
|
-
"mockttp": "2.
|
|
76
|
+
"jest": "27.5.1",
|
|
77
|
+
"lint-staged": "12.3.4",
|
|
78
|
+
"mockttp": "2.6.0",
|
|
79
79
|
"open": "8.4.0",
|
|
80
80
|
"prettier": "2.5.1",
|
|
81
81
|
"supertest": "6.2.2",
|
|
82
82
|
"ts-jest": "27.1.3",
|
|
83
83
|
"typescript": "4.5.5",
|
|
84
|
-
"ws": "8.
|
|
84
|
+
"ws": "8.5.0"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@types/http-proxy": "^1.17.8",
|