Skip to content

Commit 47b0f58

Browse files
anton-tiptyukquarryman
authored andcommitted
+= request/response logging
1 parent c91b08b commit 47b0f58

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

scripts/start.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ var pathExists = require('path-exists');
2222
var config = require('../config/webpack.config.dev');
2323
var paths = require('../config/paths');
2424

25+
const StringDecoder = require('string_decoder').StringDecoder;
26+
2527
var useYarn = pathExists.sync(paths.yarnLockFile);
2628
var cli = useYarn ? 'yarn' : 'npm';
2729
var 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

Comments
 (0)