@@ -54,7 +54,7 @@ module.exports = function prepareProxy (proxy, appPublicFolder) {
54
54
return ! ( isPublicFileRequest || isWdsEndpointRequest )
55
55
}
56
56
57
- function createProxyEntry ( target , usersOnProxyReq , context ) {
57
+ function createProxyEntry ( target , usersOnProxyReq , usersOnError , context ) {
58
58
// #2478
59
59
// There're a little-known use case that the `target` field is an object rather than a string
60
60
// https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/https.md
@@ -97,7 +97,7 @@ module.exports = function prepareProxy (proxy, appPublicFolder) {
97
97
proxyReq . setHeader ( 'origin' , target )
98
98
}
99
99
} ,
100
- onError : onProxyError ( target )
100
+ onError : usersOnError ? ( err , req , res ) => usersOnError ( err , req , res , target ) : onDefaultProxyError ( target )
101
101
}
102
102
}
103
103
@@ -129,7 +129,7 @@ module.exports = function prepareProxy (proxy, appPublicFolder) {
129
129
)
130
130
process . exit ( 1 )
131
131
}
132
- const entry = createProxyEntry ( config . target , config . onProxyReq , context )
132
+ const entry = createProxyEntry ( config . target , config . onProxyReq , config . onError , context )
133
133
return Object . assign ( { } , defaultConfig , config , entry )
134
134
} )
135
135
}
@@ -163,9 +163,9 @@ function resolveLoopback (proxy) {
163
163
return url . format ( o )
164
164
}
165
165
166
- // We need to provide a custom onError function for httpProxyMiddleware.
166
+ // We need to provide a default custom onError function for httpProxyMiddleware.
167
167
// It allows us to log custom error messages on the console.
168
- function onProxyError ( proxy ) {
168
+ function onDefaultProxyError ( proxy ) {
169
169
return ( err , req , res ) => {
170
170
const host = req . headers && req . headers . host
171
171
console . log (
0 commit comments