@@ -22,6 +22,8 @@ var pathExists = require('path-exists');
2222var config = require ( '../config/webpack.config.dev' ) ;
2323var paths = require ( '../config/paths' ) ;
2424
25+ const StringDecoder = require ( 'string_decoder' ) . StringDecoder ;
26+
2527var useYarn = pathExists . sync ( paths . yarnLockFile ) ;
2628var cli = useYarn ? 'yarn' : 'npm' ;
2729var isInteractive = process . stdout . isTTY ;
@@ -198,8 +200,18 @@ function addMiddleware(devServer) {
198200 var hpm = httpProxyMiddleware ( path => mayProxy . test ( path ) , {
199201 target : proxy ,
200202 logLevel : 'silent' ,
201- onProxyReq : function ( proxyReq , req , res ) {
203+ onProxyReq : ( proxyReq , req , res ) => {
202204 proxyReq . setHeader ( 'authorization' , token ) ;
205+ console . log ( `requested: [${ req . method } ] ${ req . url } ` ) ;
206+ console . log ( 'query:' , req . query ) ;
207+ console . log ( '-\n' ) ;
208+ } ,
209+ onProxyRes : ( proxyRes , req , res ) => {
210+ proxyRes . on ( 'data' , ( chunk ) => {
211+ console . log ( `response for: [${ req . method } ] ${ req . url } ` ) ;
212+ console . log ( ( new StringDecoder ( 'utf8' ) ) . write ( chunk ) ) ;
213+ console . log ( '-\n' ) ;
214+ } ) ;
203215 } ,
204216 // pathRewrite: {
205217 // // '^/api/old-path': '/api/new-path', // rewrite path
0 commit comments