You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// We need to provide a custom onError function for httpProxyMiddleware.
7
+
// It allows us to log custom error messages on the console.
8
+
functiononProxyError(proxy){
9
+
returnfunction(err,req,res){
10
+
varhost=req.headers&&req.headers.host;
11
+
console.log(
12
+
chalk.red('Proxy error:')+' Could not proxy request '+chalk.cyan(req.url)+
13
+
' from '+chalk.cyan(host)+' to '+chalk.cyan(proxy)+'.'
14
+
);
15
+
console.log(
16
+
'See https://nodejs.org/api/errors.html#errors_common_system_errors for more information ('+
17
+
chalk.cyan(err.code)+').'
18
+
);
19
+
console.log();
20
+
21
+
// And immediately send the proper error response to the client.
22
+
// Otherwise, the request will eventually timeout with ERR_EMPTY_RESPONSE on the client side.
23
+
if(res.writeHead&&!res.headersSent){
24
+
res.writeHead(500);
25
+
}
26
+
res.end('Proxy error: Could not proxy request '+req.url+' from '+
// `proxy` lets you to specify a fallback server during development.
8
34
// Every unrecognized request will be forwarded to it.
9
35
varproxy=require(paths.appPackageJson).proxy;
@@ -54,7 +80,8 @@ module.exports = function addMiddleware(devServer) {
54
80
onError: onProxyError(proxy),
55
81
secure: false,
56
82
changeOrigin: true,
57
-
ws: true
83
+
ws: true,
84
+
xfwd: true
58
85
});
59
86
devServer.use(mayProxy,hpm);
60
87
@@ -68,29 +95,3 @@ module.exports = function addMiddleware(devServer) {
68
95
// It may be /index.html, so let the dev server try serving it again.
69
96
devServer.use(devServer.middleware);
70
97
};
71
-
72
-
// We need to provide a custom onError function for httpProxyMiddleware.
73
-
// It allows us to log custom error messages on the console.
74
-
functiononProxyError(proxy){
75
-
returnfunction(err,req,res){
76
-
varhost=req.headers&&req.headers.host;
77
-
console.log(
78
-
chalk.red('Proxy error:')+' Could not proxy request '+chalk.cyan(req.url)+
79
-
' from '+chalk.cyan(host)+' to '+chalk.cyan(proxy)+'.'
80
-
);
81
-
console.log(
82
-
'See https://nodejs.org/api/errors.html#errors_common_system_errors for more information ('+
83
-
chalk.cyan(err.code)+').'
84
-
);
85
-
console.log();
86
-
87
-
// And immediately send the proper error response to the client.
88
-
// Otherwise, the request will eventually timeout with ERR_EMPTY_RESPONSE on the client side.
89
-
if(res.writeHead&&!res.headersSent){
90
-
res.writeHead(500);
91
-
}
92
-
res.end('Proxy error: Could not proxy request '+req.url+' from '+
0 commit comments