@@ -41,7 +41,7 @@ module.exports = ({ port = null, config = {}, filters = {} }) => {
41
41
} ) ;
42
42
43
43
app . get ( config . brokerSystemcheckPath || '/systemcheck' , ( req , res ) => {
44
- // Systemcheck is the broker client's ability to assert the network
44
+ // Systemcheck is the broker client's ability to assert the network
45
45
// reachability and some correctness of credentials for the service
46
46
// being proxied by the broker client.
47
47
@@ -89,20 +89,26 @@ module.exports = ({ port = null, config = {}, filters = {} }) => {
89
89
return res . status ( 500 ) . json ( data ) ;
90
90
}
91
91
92
- data . brokerClientValidationUrlStatusCode = response && response . statusCode ;
92
+ const responseStatusCode = response && response . statusCode ;
93
+ data . brokerClientValidationUrlStatusCode = responseStatusCode ;
94
+
93
95
// check for 2xx status code
94
- const goodStatusCode = / ^ 2 / . test ( response && response . statusCode ) ;
96
+ const goodStatusCode = / ^ 2 / . test ( responseStatusCode ) ;
95
97
if ( ! goodStatusCode ) {
96
98
data . ok = false ;
97
- data . error = 'Status code is not 2xx' ;
99
+ data . error = ( responseStatusCode === 401 || responseStatusCode === 403 )
100
+ ? 'Failed due to invalid credentials'
101
+ : 'Status code is not 2xx' ;
102
+
103
+ logger . error ( data , response && response . body , 'Systemcheck failed' ) ;
98
104
return res . status ( 500 ) . json ( data ) ;
99
105
}
100
106
101
107
data . ok = true ;
102
108
return res . status ( 200 ) . json ( data ) ;
103
109
} ) ;
104
110
} ) ;
105
-
111
+
106
112
// relay all other URL paths
107
113
app . all ( '/*' , ( req , res , next ) => {
108
114
res . locals . io = io ;
0 commit comments