Skip to content

Commit 27a29a3

Browse files
authored
fix: deprecation warning when using proxy with Node 22 (#4347)
1 parent f84a8c7 commit 27a29a3

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
"typescript": "^5.7.2",
5353
"vitest": "^2.1.8"
5454
},
55+
"pnpm": {
56+
"patchedDependencies": {
57+
58+
}
59+
},
5560
"packageManager": "[email protected]",
5661
"engines": {
5762
"node": ">=18.0.0",

patches/[email protected]

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# ref: https://github.com/web-infra-dev/rsbuild/issues/4344
2+
diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js
3+
index 6513e81d80d5250ea249ea833f819ece67897c7e..486d4c896d65a3bb7cf63307af68facb3ddb886b 100644
4+
--- a/lib/http-proxy/common.js
5+
+++ b/lib/http-proxy/common.js
6+
@@ -1,6 +1,5 @@
7+
var common = exports,
8+
url = require('url'),
9+
- extend = require('util')._extend,
10+
required = require('requires-port');
11+
12+
var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i,
13+
@@ -40,10 +39,10 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
14+
);
15+
16+
outgoing.method = options.method || req.method;
17+
- outgoing.headers = extend({}, req.headers);
18+
+ outgoing.headers = Object.assign({}, req.headers);
19+
20+
if (options.headers){
21+
- extend(outgoing.headers, options.headers);
22+
+ Object.assign(outgoing.headers, options.headers);
23+
}
24+
25+
if (options.auth) {
26+
diff --git a/lib/http-proxy/index.js b/lib/http-proxy/index.js
27+
index 977a4b3622b9eaac27689f06347ea4c5173a96cd..88b2d0fcfa03c3aafa47c7e6d38e64412c45a7cc 100644
28+
--- a/lib/http-proxy/index.js
29+
+++ b/lib/http-proxy/index.js
30+
@@ -1,5 +1,4 @@
31+
var httpProxy = module.exports,
32+
- extend = require('util')._extend,
33+
parse_url = require('url').parse,
34+
EE3 = require('eventemitter3'),
35+
http = require('http'),
36+
@@ -47,9 +46,9 @@ function createRightProxy(type) {
37+
args[cntr] !== res
38+
) {
39+
//Copy global options
40+
- requestOptions = extend({}, options);
41+
+ requestOptions = Object.assign({}, options);
42+
//Overwrite with request options
43+
- extend(requestOptions, args[cntr]);
44+
+ Object.assign(requestOptions, args[cntr]);
45+
46+
cntr--;
47+
}

pnpm-lock.yaml

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)