@@ -25,43 +25,45 @@ const proxy_options = {
25
25
pathRewrite: {
26
26
' ^/docs' : ' /java/rep/server1' , // Host path & target path conversion
27
27
},
28
- onError (err , req , res ) {
29
- res .writeHead (500 , {
30
- ' Content-Type' : ' text/plain' ,
31
- });
32
- res .end (' Something went wrong. And we are reporting a custom error message.' + err);
33
- },
34
- onProxyReq (proxyReq , req , res ) {
35
- if (req .method == ' POST' && req .body ) {
36
- // Add req.body logic here if needed....
37
-
38
- // ....
39
-
40
- // Remove body-parser body object from the request
41
- if (req .body ) delete req .body ;
42
-
43
- // Make any needed POST parameter changes
44
- let body = new Object ();
45
-
46
- body .filename = ' reports/statistics/summary_2016.pdf' ;
47
- body .routeId = ' s003b012d002' ;
48
- body .authId = ' bac02c1d-258a-4177-9da6-862580154960' ;
49
-
50
- // URI encode JSON object
51
- body = Object .keys (body)
52
- .map (function (key ) {
53
- return encodeURIComponent (key) + ' =' + encodeURIComponent (body[key]);
54
- })
55
- .join (' &' );
56
-
57
- // Update header
58
- proxyReq .setHeader (' content-type' , ' application/x-www-form-urlencoded' );
59
- proxyReq .setHeader (' content-length' , body .length );
60
-
61
- // Write out body changes to the proxyReq stream
62
- proxyReq .write (body);
63
- proxyReq .end ();
64
- }
28
+ on: {
29
+ error (err , req , res ) {
30
+ res .writeHead (500 , {
31
+ ' Content-Type' : ' text/plain' ,
32
+ });
33
+ res .end (' Something went wrong. And we are reporting a custom error message.' + err);
34
+ },
35
+ proxyReq (proxyReq , req , res ) {
36
+ if (req .method == ' POST' && req .body ) {
37
+ // Add req.body logic here if needed....
38
+
39
+ // ....
40
+
41
+ // Remove body-parser body object from the request
42
+ if (req .body ) delete req .body ;
43
+
44
+ // Make any needed POST parameter changes
45
+ let body = new Object ();
46
+
47
+ body .filename = ' reports/statistics/summary_2016.pdf' ;
48
+ body .routeId = ' s003b012d002' ;
49
+ body .authId = ' bac02c1d-258a-4177-9da6-862580154960' ;
50
+
51
+ // URI encode JSON object
52
+ body = Object .keys (body)
53
+ .map (function (key ) {
54
+ return encodeURIComponent (key) + ' =' + encodeURIComponent (body[key]);
55
+ })
56
+ .join (' &' );
57
+
58
+ // Update header
59
+ proxyReq .setHeader (' content-type' , ' application/x-www-form-urlencoded' );
60
+ proxyReq .setHeader (' content-length' , body .length );
61
+
62
+ // Write out body changes to the proxyReq stream
63
+ proxyReq .write (body);
64
+ proxyReq .end ();
65
+ }
66
+ },
65
67
},
66
68
};
67
69
0 commit comments