question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

With reference to the recipe to manipulate the request object posted at https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/modify-post.md

onProxyReq

var onProxyReq = function(proxyReq, req, res) {
    if ( (req.method == "POST" || req.method == "PUT") ) {
        console.log('######## POST Request');
        console.log(req);
    }
};

This is the request object I am sending from my client:

"{"method":"POST","transformRequest":[null],"transformResponse":[null],"url":"/api/cli/labels/","data":{"color":"#ab30ac","name":"newlbl","type":"IP"},"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json;charset=utf-8","Authorization":"Bearer XXXXXXXX","XXXXXX":1505506463,"XXXXXXX":"1.3.0"},"cached":false}"

But, I am not seeing any body in the output. Here’s the output I am seeing.

Console Log output

0|Phi      | ######## POST Request
0|Phi      | IncomingMessage {
0|Phi      |   _readableState:
0|Phi      |    ReadableState {
0|Phi      |      objectMode: false,
0|Phi      |      highWaterMark: 16384,
0|Phi      |      buffer: BufferList { head: [Object], tail: [Object], length: 1 },
0|Phi      |      length: 47,
0|Phi      |      pipes:
0|Phi      |       ClientRequest {
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 7,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         output: [],
0|Phi      |         outputEncodings: [],
0|Phi      |         outputCallbacks: [],
0|Phi      |         outputSize: 0,
0|Phi      |         writable: true,
0|Phi      |         _last: true,
0|Phi      |         upgrading: false,
0|Phi      |         chunkedEncoding: false,
0|Phi      |         shouldKeepAlive: false,
0|Phi      |         useChunkedEncodingByDefault: true,
0|Phi      |         sendDate: false,
0|Phi      |         _removedHeader: [Object],
0|Phi      |         _contentLength: null,
0|Phi      |         _hasBody: true,
0|Phi      |         _trailer: '',
0|Phi      |         finished: false,
0|Phi      |         _headerSent: false,
0|Phi      |         socket: [Object],
0|Phi      |         connection: [Object],
0|Phi      |         _header: null,
0|Phi      |         _headers: [Object],
0|Phi      |         _headerNames: [Object],
0|Phi      |         _onPendingData: null,
0|Phi      |         agent: [Object],
0|Phi      |         socketPath: undefined,
0|Phi      |         timeout: undefined,
0|Phi      |         method: 'POST',
0|Phi      |         path: '/cli/v1/labels/',
0|Phi      |         _ended: false,
0|Phi      |         res: null,
0|Phi      |         aborted: undefined,
0|Phi      |         timeoutCb: null,
0|Phi      |         upgradeOrConnect: false,
0|Phi      |         parser: [Object],
0|Phi      |         maxHeadersCount: null },
0|Phi      |      pipesCount: 1,
0|Phi      |      flowing: true,
0|Phi      |      ended: false,
0|Phi      |      endEmitted: false,
0|Phi      |      reading: false,
0|Phi      |      sync: true,
0|Phi      |      needReadable: false,
0|Phi      |      emittedReadable: false,
0|Phi      |      readableListening: false,
0|Phi      |      resumeScheduled: true,
0|Phi      |      defaultEncoding: 'utf8',
0|Phi      |      ranOut: false,
0|Phi      |      awaitDrain: 0,
0|Phi      |      readingMore: true,
0|Phi      |      decoder: null,
0|Phi      |      encoding: null },
0|Phi      |   readable: true,
0|Phi      |   domain: null,
0|Phi      |   _events:
0|Phi      |    { aborted: [Function],
0|Phi      |      error: [Function: proxyError],
0|Phi      |      end: { [Function: bound onceWrapper] listener: [Function: onend] },
0|Phi      |      data: [Function: ondata] },
0|Phi      |   _eventsCount: 4,
0|Phi      |   _maxListeners: undefined,
0|Phi      |   socket:
0|Phi      |    Socket {
0|Phi      |      connecting: false,
0|Phi      |      _hadError: false,
0|Phi      |      _handle:
0|Phi      |       TCP {
0|Phi      |         bytesRead: 605,
0|Phi      |         _externalStream: {},
0|Phi      |         fd: 12,
0|Phi      |         reading: true,
0|Phi      |         owner: [Circular],
0|Phi      |         onread: [Function: onread],
0|Phi      |         onconnection: null,
0|Phi      |         writeQueueSize: 0 },
0|Phi      |      _parent: null,
0|Phi      |      _host: null,
0|Phi      |      _readableState:
0|Phi      |       ReadableState {
0|Phi      |         objectMode: false,
0|Phi      |         highWaterMark: 16384,
0|Phi      |         buffer: [Object],
0|Phi      |         length: 0,
0|Phi      |         pipes: null,
0|Phi      |         pipesCount: 0,
0|Phi      |         flowing: true,
0|Phi      |         ended: false,
0|Phi      |         endEmitted: false,
0|Phi      |         reading: true,
0|Phi      |         sync: false,
0|Phi      |         needReadable: true,
0|Phi      |         emittedReadable: false,
0|Phi      |         readableListening: false,
0|Phi      |         resumeScheduled: false,
0|Phi      |         defaultEncoding: 'utf8',
0|Phi      |         ranOut: false,
0|Phi      |         awaitDrain: 0,
0|Phi      |         readingMore: false,
0|Phi      |         decoder: null,
0|Phi      |         encoding: null },
0|Phi      |      readable: true,
0|Phi      |      domain: null,
0|Phi      |      _events:
0|Phi      |       { end: [Object],
0|Phi      |         finish: [Function: onSocketFinish],
0|Phi      |         _socketEnd: [Function: onSocketEnd],
0|Phi      |         drain: [Object],
0|Phi      |         timeout: [Function: bound socketOnTimeout],
0|Phi      |         data: [Function: bound socketOnData],
0|Phi      |         error: [Function: bound socketOnError],
0|Phi      |         close: [Object],
0|Phi      |         resume: [Function: onSocketResume],
0|Phi      |         pause: [Function: onSocketPause] },
0|Phi      |      _eventsCount: 10,
0|Phi      |      _maxListeners: undefined,
0|Phi      |      _writableState:
0|Phi      |       WritableState {
0|Phi      |         objectMode: false,
0|Phi      |         highWaterMark: 16384,
0|Phi      |         needDrain: false,
0|Phi      |         ending: false,
0|Phi      |         ended: false,
0|Phi      |         finished: false,
0|Phi      |         decodeStrings: false,
0|Phi      |         defaultEncoding: 'utf8',
0|Phi      |         length: 0,
0|Phi      |         writing: false,
0|Phi      |         corked: 0,
0|Phi      |         sync: true,
0|Phi      |         bufferProcessing: false,
0|Phi      |         onwrite: [Function: bound onwrite],
0|Phi      |         writecb: null,
0|Phi      |         writelen: 0,
0|Phi      |         bufferedRequest: null,
0|Phi      |         lastBufferedRequest: null,
0|Phi      |         pendingcb: 0,
0|Phi      |         prefinished: false,
0|Phi      |         errorEmitted: false,
0|Phi      |         bufferedRequestCount: 0,
0|Phi      |         corkedRequestsFree: [Object] },
0|Phi      |      writable: true,
0|Phi      |      allowHalfOpen: true,
0|Phi      |      destroyed: false,
0|Phi      |      _bytesDispatched: 0,
0|Phi      |      _sockname: null,
0|Phi      |      _pendingData: null,
0|Phi      |      _pendingEncoding: '',
0|Phi      |      server:
0|Phi      |       Server {
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 2,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         _connections: 1,
0|Phi      |         _handle: [Object],
0|Phi      |         _usingSlaves: false,
0|Phi      |         _slaves: [],
0|Phi      |         _unref: false,
0|Phi      |         allowHalfOpen: true,
0|Phi      |         pauseOnConnect: false,
0|Phi      |         httpAllowHalfOpen: false,
0|Phi      |         timeout: 120000,
0|Phi      |         _pendingResponseData: 0,
0|Phi      |         maxHeadersCount: null,
0|Phi      |         _connectionKey: '4:0.0.0.0:3000' },
0|Phi      |      _server:
0|Phi      |       Server {
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 2,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         _connections: 1,
0|Phi      |         _handle: [Object],
0|Phi      |         _usingSlaves: false,
0|Phi      |         _slaves: [],
0|Phi      |         _unref: false,
0|Phi      |         allowHalfOpen: true,
0|Phi      |         pauseOnConnect: false,
0|Phi      |         httpAllowHalfOpen: false,
0|Phi      |         timeout: 120000,
0|Phi      |         _pendingResponseData: 0,
0|Phi      |         maxHeadersCount: null,
0|Phi      |         _connectionKey: '4:0.0.0.0:3000' },
0|Phi      |      _idleTimeout: 120000,
0|Phi      |      _idleNext:
0|Phi      |       TimersList {
0|Phi      |         _idleNext: [Circular],
0|Phi      |         _idlePrev: [Circular],
0|Phi      |         _timer: [Object],
0|Phi      |         _unrefed: true,
0|Phi      |         msecs: 120000 },
0|Phi      |      _idlePrev:
0|Phi      |       TimersList {
0|Phi      |         _idleNext: [Circular],
0|Phi      |         _idlePrev: [Circular],
0|Phi      |         _timer: [Object],
0|Phi      |         _unrefed: true,
0|Phi      |         msecs: 120000 },
0|Phi      |      _idleStart: 22901,
0|Phi      |      parser:
0|Phi      |       HTTPParser {
0|Phi      |         '0': [Function: parserOnHeaders],
0|Phi      |         '1': [Function: parserOnHeadersComplete],
0|Phi      |         '2': [Function: parserOnBody],
0|Phi      |         '3': [Function: parserOnMessageComplete],
0|Phi      |         '4': [Function: bound onParserExecute],
0|Phi      |         _headers: [],
0|Phi      |         _url: '',
0|Phi      |         _consumed: true,
0|Phi      |         socket: [Circular],
0|Phi      |         incoming: [Circular],
0|Phi      |         outgoing: null,
0|Phi      |         maxHeaderPairs: 2000,
0|Phi      |         onIncoming: [Function: bound parserOnIncoming] },
0|Phi      |      on: [Function: socketOnWrap],
0|Phi      |      _paused: false,
0|Phi      |      read: [Function],
0|Phi      |      _consuming: true,
0|Phi      |      _httpMessage:
0|Phi      |       ServerResponse {
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 1,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         output: [],
0|Phi      |         outputEncodings: [],
0|Phi      |         outputCallbacks: [],
0|Phi      |         outputSize: 0,
0|Phi      |         writable: true,
0|Phi      |         _last: false,
0|Phi      |         upgrading: false,
0|Phi      |         chunkedEncoding: false,
0|Phi      |         shouldKeepAlive: true,
0|Phi      |         useChunkedEncodingByDefault: true,
0|Phi      |         sendDate: true,
0|Phi      |         _removedHeader: {},
0|Phi      |         _contentLength: null,
0|Phi      |         _hasBody: true,
0|Phi      |         _trailer: '',
0|Phi      |         finished: false,
0|Phi      |         _headerSent: false,
0|Phi      |         socket: [Circular],
0|Phi      |         connection: [Circular],
0|Phi      |         _header: null,
0|Phi      |         _headers: [Object],
0|Phi      |         _headerNames: [Object],
0|Phi      |         _onPendingData: [Function: bound updateOutgoingData],
0|Phi      |         _sent100: false,
0|Phi      |         _expect_continue: false,
0|Phi      |         req: [Circular],
0|Phi      |         locals: {} } },
0|Phi      |   connection:
0|Phi      |    Socket {
0|Phi      |      connecting: false,
0|Phi      |      _hadError: false,
0|Phi      |      _handle:
0|Phi      |       TCP {
0|Phi      |         bytesRead: 605,
0|Phi      |         _externalStream: {},
0|Phi      |         fd: 12,
0|Phi      |         reading: true,
0|Phi      |         owner: [Circular],
0|Phi      |         onread: [Function: onread],
0|Phi      |         onconnection: null,
0|Phi      |         writeQueueSize: 0 },
0|Phi      |      _parent: null,
0|Phi      |      _host: null,
0|Phi      |      _readableState:
0|Phi      |       ReadableState {
0|Phi      |         objectMode: false,
0|Phi      |         highWaterMark: 16384,
0|Phi      |         buffer: [Object],
0|Phi      |         length: 0,
0|Phi      |         pipes: null,
0|Phi      |         pipesCount: 0,
0|Phi      |         flowing: true,
0|Phi      |         ended: false,
0|Phi      |         endEmitted: false,
0|Phi      |         reading: true,
0|Phi      |         sync: false,
0|Phi      |         needReadable: true,
0|Phi      |         emittedReadable: false,
0|Phi      |         readableListening: false,
0|Phi      |         resumeScheduled: false,
0|Phi      |         defaultEncoding: 'utf8',
0|Phi      |         ranOut: false,
0|Phi      |         awaitDrain: 0,
0|Phi      |         readingMore: false,
0|Phi      |         decoder: null,
0|Phi      |         encoding: null },
0|Phi      |      readable: true,
0|Phi      |      domain: null,
0|Phi      |      _events:
0|Phi      |       { end: [Object],
0|Phi      |         finish: [Function: onSocketFinish],
0|Phi      |         _socketEnd: [Function: onSocketEnd],
0|Phi      |         drain: [Object],
0|Phi      |         timeout: [Function: bound socketOnTimeout],
0|Phi      |         data: [Function: bound socketOnData],
0|Phi      |         error: [Function: bound socketOnError],
0|Phi      |         close: [Object],
0|Phi      |         resume: [Function: onSocketResume],
0|Phi      |         pause: [Function: onSocketPause] },
0|Phi      |      _eventsCount: 10,
0|Phi      |      _maxListeners: undefined,
0|Phi      |      _writableState:
0|Phi      |       WritableState {
0|Phi      |         objectMode: false,
0|Phi      |         highWaterMark: 16384,
0|Phi      |         needDrain: false,
0|Phi      |         ending: false,
0|Phi      |         ended: false,
0|Phi      |         finished: false,
0|Phi      |         decodeStrings: false,
0|Phi      |         defaultEncoding: 'utf8',
0|Phi      |         length: 0,
0|Phi      |         writing: false,
0|Phi      |         corked: 0,
0|Phi      |         sync: true,
0|Phi      |         bufferProcessing: false,
0|Phi      |         onwrite: [Function: bound onwrite],
0|Phi      |         writecb: null,
0|Phi      |         writelen: 0,
0|Phi      |         bufferedRequest: null,
0|Phi      |         lastBufferedRequest: null,
0|Phi      |         pendingcb: 0,
0|Phi      |         prefinished: false,
0|Phi      |         errorEmitted: false,
0|Phi      |         bufferedRequestCount: 0,
0|Phi      |         corkedRequestsFree: [Object] },
0|Phi      |      writable: true,
0|Phi      |      allowHalfOpen: true,
0|Phi      |      destroyed: false,
0|Phi      |      _bytesDispatched: 0,
0|Phi      |      _sockname: null,
0|Phi      |      _pendingData: null,
0|Phi      |      _pendingEncoding: '',
0|Phi      |      server:
0|Phi      |       Server {
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 2,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         _connections: 1,
0|Phi      |         _handle: [Object],
0|Phi      |         _usingSlaves: false,
0|Phi      |         _slaves: [],
0|Phi      |         _unref: false,
0|Phi      |         allowHalfOpen: true,
0|Phi      |         pauseOnConnect: false,
0|Phi      |         httpAllowHalfOpen: false,
0|Phi      |         timeout: 120000,
0|Phi      |         _pendingResponseData: 0,
0|Phi      |         maxHeadersCount: null,
0|Phi      |         _connectionKey: '4:0.0.0.0:3000' },
0|Phi      |      _server:
0|Phi      |       Server {
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 2,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         _connections: 1,
0|Phi      |         _handle: [Object],
0|Phi      |         _usingSlaves: false,
0|Phi      |         _slaves: [],
0|Phi      |         _unref: false,
0|Phi      |         allowHalfOpen: true,
0|Phi      |         pauseOnConnect: false,
0|Phi      |         httpAllowHalfOpen: false,
0|Phi      |         timeout: 120000,
0|Phi      |         _pendingResponseData: 0,
0|Phi      |         maxHeadersCount: null,
0|Phi      |         _connectionKey: '4:0.0.0.0:3000' },
0|Phi      |      _idleTimeout: 120000,
0|Phi      |      _idleNext:
0|Phi      |       TimersList {
0|Phi      |         _idleNext: [Circular],
0|Phi      |         _idlePrev: [Circular],
0|Phi      |         _timer: [Object],
0|Phi      |         _unrefed: true,
0|Phi      |         msecs: 120000 },
0|Phi      |      _idlePrev:
0|Phi      |       TimersList {
0|Phi      |         _idleNext: [Circular],
0|Phi      |         _idlePrev: [Circular],
0|Phi      |         _timer: [Object],
0|Phi      |         _unrefed: true,
0|Phi      |         msecs: 120000 },
0|Phi      |      _idleStart: 22901,
0|Phi      |      parser:
0|Phi      |       HTTPParser {
0|Phi      |         '0': [Function: parserOnHeaders],
0|Phi      |         '1': [Function: parserOnHeadersComplete],
0|Phi      |         '2': [Function: parserOnBody],
0|Phi      |         '3': [Function: parserOnMessageComplete],
0|Phi      |         '4': [Function: bound onParserExecute],
0|Phi      |         _headers: [],
0|Phi      |         _url: '',
0|Phi      |         _consumed: true,
0|Phi      |         socket: [Circular],
0|Phi      |         incoming: [Circular],
0|Phi      |         outgoing: null,
0|Phi      |         maxHeaderPairs: 2000,
0|Phi      |         onIncoming: [Function: bound parserOnIncoming] },
0|Phi      |      on: [Function: socketOnWrap],
0|Phi      |      _paused: false,
0|Phi      |      read: [Function],
0|Phi      |      _consuming: true,
0|Phi      |      _httpMessage:
0|Phi      |       ServerResponse {
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 1,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         output: [],
0|Phi      |         outputEncodings: [],
0|Phi      |         outputCallbacks: [],
0|Phi      |         outputSize: 0,
0|Phi      |         writable: true,
0|Phi      |         _last: false,
0|Phi      |         upgrading: false,
0|Phi      |         chunkedEncoding: false,
0|Phi      |         shouldKeepAlive: true,
0|Phi      |         useChunkedEncodingByDefault: true,
0|Phi      |         sendDate: true,
0|Phi      |         _removedHeader: {},
0|Phi      |         _contentLength: null,
0|Phi      |         _hasBody: true,
0|Phi      |         _trailer: '',
0|Phi      |         finished: false,
0|Phi      |         _headerSent: false,
0|Phi      |         socket: [Circular],
0|Phi      |         connection: [Circular],
0|Phi      |         _header: null,
0|Phi      |         _headers: [Object],
0|Phi      |         _headerNames: [Object],
0|Phi      |         _onPendingData: [Function: bound updateOutgoingData],
0|Phi      |         _sent100: false,
0|Phi      |         _expect_continue: false,
0|Phi      |         req: [Circular],
0|Phi      |         locals: {} } },
0|Phi      |   httpVersionMajor: 1,
0|Phi      |   httpVersionMinor: 1,
0|Phi      |   httpVersion: '1.1',
0|Phi      |   complete: false,
0|Phi      |   headers:
0|Phi      |    { host: 'vm:3000',
0|Phi      |      connection: 'keep-alive',
0|Phi      |      'content-length': '47',
0|Phi      |      origin: 'http://vm:3000',
0|Phi      |      'XXXXXXXXXX': '1.3.0',
0|Phi      |      authorization: 'Bearer XXXXXXXXX',
0|Phi      |      'content-type': 'application/json;charset=UTF-8',
0|Phi      |      accept: 'application/json, text/plain, */*',
0|Phi      |      'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.71 Safari/537.36',
0|Phi      |      'XXXXXXX': '1505503300',
0|Phi      |      dnt: '1',
0|Phi      |      referer: 'http://vm:3000/',
0|Phi      |      'accept-encoding': 'gzip, deflate',
0|Phi      |      'accept-language': 'en-US,en;q=0.8' },
0|Phi      |   rawHeaders:
0|Phi      |    [ 'Host',
0|Phi      |      'vm:3000',
0|Phi      |      'Connection',
0|Phi      |      'keep-alive',
0|Phi      |      'Content-Length',
0|Phi      |      '47',
0|Phi      |      'Origin',
0|Phi      |      'http://vm:3000',
0|Phi      |      'XXXXXXXXXX',
0|Phi      |      '1.3.0',
0|Phi      |      'Authorization',
0|Phi      |      'Bearer XXXXXXX',
0|Phi      |      'Content-Type',
0|Phi      |      'application/json;charset=UTF-8',
0|Phi      |      'Accept',
0|Phi      |      'application/json, text/plain, */*',
0|Phi      |      'User-Agent',
0|Phi      |      'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.71 Safari/537.36',
0|Phi      |      'XXXXXXXX',
0|Phi      |      '1505503300',
0|Phi      |      'DNT',
0|Phi      |      '1',
0|Phi      |      'Referer',
0|Phi      |      'http://vm:3000/',
0|Phi      |      'Accept-Encoding',
0|Phi      |      'gzip, deflate',
0|Phi      |      'Accept-Language',
0|Phi      |      'en-US,en;q=0.8' ],
0|Phi      |   trailers: {},
0|Phi      |   rawTrailers: [],
0|Phi      |   upgrade: false,
0|Phi      |   url: '/cli/v1/labels/',
0|Phi      |   method: 'POST',
0|Phi      |   statusCode: null,
0|Phi      |   statusMessage: null,
0|Phi      |   client:
0|Phi      |    Socket {
0|Phi      |      connecting: false,
0|Phi      |      _hadError: false,
0|Phi      |      _handle:
0|Phi      |       TCP {
0|Phi      |         bytesRead: 605,
0|Phi      |         _externalStream: {},
0|Phi      |         fd: 12,
0|Phi      |         reading: true,
0|Phi      |         owner: [Circular],
0|Phi      |         onread: [Function: onread],
0|Phi      |         onconnection: null,
0|Phi      |         writeQueueSize: 0 },
0|Phi      |      _parent: null,
0|Phi      |      _host: null,
0|Phi      |      _readableState:
0|Phi      |       ReadableState {
0|Phi      |         objectMode: false,
0|Phi      |         highWaterMark: 16384,
0|Phi      |         buffer: [Object],
0|Phi      |         length: 0,
0|Phi      |         pipes: null,
0|Phi      |         pipesCount: 0,
0|Phi      |         flowing: true,
0|Phi      |         ended: false,
0|Phi      |         endEmitted: false,
0|Phi      |         reading: true,
0|Phi      |         sync: false,
0|Phi      |         needReadable: true,
0|Phi      |         emittedReadable: false,
0|Phi      |         readableListening: false,
0|Phi      |         resumeScheduled: false,
0|Phi      |         defaultEncoding: 'utf8',
0|Phi      |         ranOut: false,
0|Phi      |         awaitDrain: 0,
0|Phi      |         readingMore: false,
0|Phi      |         decoder: null,
0|Phi      |         encoding: null },
0|Phi      |      readable: true,
0|Phi      |      domain: null,
0|Phi      |      _events:
0|Phi      |       { end: [Object],
0|Phi      |         finish: [Function: onSocketFinish],
0|Phi      |         _socketEnd: [Function: onSocketEnd],
0|Phi      |         drain: [Object],
0|Phi      |         timeout: [Function: bound socketOnTimeout],
0|Phi      |         data: [Function: bound socketOnData],
0|Phi      |         error: [Function: bound socketOnError],
0|Phi      |         close: [Object],
0|Phi      |         resume: [Function: onSocketResume],
0|Phi      |         pause: [Function: onSocketPause] },
0|Phi      |      _eventsCount: 10,
0|Phi      |      _maxListeners: undefined,
0|Phi      |      _writableState:
0|Phi      |       WritableState {
0|Phi      |         objectMode: false,
0|Phi      |         highWaterMark: 16384,
0|Phi      |         needDrain: false,
0|Phi      |         ending: false,
0|Phi      |         ended: false,
0|Phi      |         finished: false,
0|Phi      |         decodeStrings: false,
0|Phi      |         defaultEncoding: 'utf8',
0|Phi      |         length: 0,
0|Phi      |         writing: false,
0|Phi      |         corked: 0,
0|Phi      |         sync: true,
0|Phi      |         bufferProcessing: false,
0|Phi      |         onwrite: [Function: bound onwrite],
0|Phi      |         writecb: null,
0|Phi      |         writelen: 0,
0|Phi      |         bufferedRequest: null,
0|Phi      |         lastBufferedRequest: null,
0|Phi      |         pendingcb: 0,
0|Phi      |         prefinished: false,
0|Phi      |         errorEmitted: false,
0|Phi      |         bufferedRequestCount: 0,
0|Phi      |         corkedRequestsFree: [Object] },
0|Phi      |      writable: true,
0|Phi      |      allowHalfOpen: true,
0|Phi      |      destroyed: false,
0|Phi      |      _bytesDispatched: 0,
0|Phi      |      _sockname: null,
0|Phi      |      _pendingData: null,
0|Phi      |      _pendingEncoding: '',
0|Phi      |      server:
0|Phi      |       Server {
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 2,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         _connections: 1,
0|Phi      |         _handle: [Object],
0|Phi      |         _usingSlaves: false,
0|Phi      |         _slaves: [],
0|Phi      |         _unref: false,
0|Phi      |         allowHalfOpen: true,
0|Phi      |         pauseOnConnect: false,
0|Phi      |         httpAllowHalfOpen: false,
0|Phi      |         timeout: 120000,
0|Phi      |         _pendingResponseData: 0,
0|Phi      |         maxHeadersCount: null,
0|Phi      |         _connectionKey: '4:0.0.0.0:3000' },
0|Phi      |      _server:
0|Phi      |       Server {
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 2,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         _connections: 1,
0|Phi      |         _handle: [Object],
0|Phi      |         _usingSlaves: false,
0|Phi      |         _slaves: [],
0|Phi      |         _unref: false,
0|Phi      |         allowHalfOpen: true,
0|Phi      |         pauseOnConnect: false,
0|Phi      |         httpAllowHalfOpen: false,
0|Phi      |         timeout: 120000,
0|Phi      |         _pendingResponseData: 0,
0|Phi      |         maxHeadersCount: null,
0|Phi      |         _connectionKey: '4:0.0.0.0:3000' },
0|Phi      |      _idleTimeout: 120000,
0|Phi      |      _idleNext:
0|Phi      |       TimersList {
0|Phi      |         _idleNext: [Circular],
0|Phi      |         _idlePrev: [Circular],
0|Phi      |         _timer: [Object],
0|Phi      |         _unrefed: true,
0|Phi      |         msecs: 120000 },
0|Phi      |      _idlePrev:
0|Phi      |       TimersList {
0|Phi      |         _idleNext: [Circular],
0|Phi      |         _idlePrev: [Circular],
0|Phi      |         _timer: [Object],
0|Phi      |         _unrefed: true,
0|Phi      |         msecs: 120000 },
0|Phi      |      _idleStart: 22901,
0|Phi      |      parser:
0|Phi      |       HTTPParser {
0|Phi      |         '0': [Function: parserOnHeaders],
0|Phi      |         '1': [Function: parserOnHeadersComplete],
0|Phi      |         '2': [Function: parserOnBody],
0|Phi      |         '3': [Function: parserOnMessageComplete],
0|Phi      |         '4': [Function: bound onParserExecute],
0|Phi      |         _headers: [],
0|Phi      |         _url: '',
0|Phi      |         _consumed: true,
0|Phi      |         socket: [Circular],
0|Phi      |         incoming: [Circular],
0|Phi      |         outgoing: null,
0|Phi      |         maxHeaderPairs: 2000,
0|Phi      |         onIncoming: [Function: bound parserOnIncoming] },
0|Phi      |      on: [Function: socketOnWrap],
0|Phi      |      _paused: false,
0|Phi      |      read: [Function],
0|Phi      |      _consuming: true,
0|Phi      |      _httpMessage:
0|Phi      |       ServerResponse {
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 1,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         output: [],
0|Phi      |         outputEncodings: [],
0|Phi      |         outputCallbacks: [],
0|Phi      |         outputSize: 0,
0|Phi      |         writable: true,
0|Phi      |         _last: false,
0|Phi      |         upgrading: false,
0|Phi      |         chunkedEncoding: false,
0|Phi      |         shouldKeepAlive: true,
0|Phi      |         useChunkedEncodingByDefault: true,
0|Phi      |         sendDate: true,
0|Phi      |         _removedHeader: {},
0|Phi      |         _contentLength: null,
0|Phi      |         _hasBody: true,
0|Phi      |         _trailer: '',
0|Phi      |         finished: false,
0|Phi      |         _headerSent: false,
0|Phi      |         socket: [Circular],
0|Phi      |         connection: [Circular],
0|Phi      |         _header: null,
0|Phi      |         _headers: [Object],
0|Phi      |         _headerNames: [Object],
0|Phi      |         _onPendingData: [Function: bound updateOutgoingData],
0|Phi      |         _sent100: false,
0|Phi      |         _expect_continue: false,
0|Phi      |         req: [Circular],
0|Phi      |         locals: {} } },
0|Phi      |   _consuming: false,
0|Phi      |   _dumped: false,
0|Phi      |   next: [Function: next],
0|Phi      |   baseUrl: '',
0|Phi      |   originalUrl: '/api/cli/labels/',
0|Phi      |   _parsedUrl:
0|Phi      |    Url {
0|Phi      |      protocol: null,
0|Phi      |      slashes: null,
0|Phi      |      auth: null,
0|Phi      |      host: null,
0|Phi      |      port: null,
0|Phi      |      hostname: null,
0|Phi      |      hash: null,
0|Phi      |      search: null,
0|Phi      |      query: null,
0|Phi      |      pathname: '/api/cli/labels/',
0|Phi      |      path: '/api/cli/labels/',
0|Phi      |      href: '/api/cli/labels/',
0|Phi      |      _raw: '/api/cli/labels/' },
0|Phi      |   params: {},
0|Phi      |   query: {},
0|Phi      |   res:
0|Phi      |    ServerResponse {
0|Phi      |      domain: null,
0|Phi      |      _events: { finish: [Function: bound resOnFinish] },
0|Phi      |      _eventsCount: 1,
0|Phi      |      _maxListeners: undefined,
0|Phi      |      output: [],
0|Phi      |      outputEncodings: [],
0|Phi      |      outputCallbacks: [],
0|Phi      |      outputSize: 0,
0|Phi      |      writable: true,
0|Phi      |      _last: false,
0|Phi      |      upgrading: false,
0|Phi      |      chunkedEncoding: false,
0|Phi      |      shouldKeepAlive: true,
0|Phi      |      useChunkedEncodingByDefault: true,
0|Phi      |      sendDate: true,
0|Phi      |      _removedHeader: {},
0|Phi      |      _contentLength: null,
0|Phi      |      _hasBody: true,
0|Phi      |      _trailer: '',
0|Phi      |      finished: false,
0|Phi      |      _headerSent: false,
0|Phi      |      socket:
0|Phi      |       Socket {
0|Phi      |         connecting: false,
0|Phi      |         _hadError: false,
0|Phi      |         _handle: [Object],
0|Phi      |         _parent: null,
0|Phi      |         _host: null,
0|Phi      |         _readableState: [Object],
0|Phi      |         readable: true,
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 10,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         _writableState: [Object],
0|Phi      |         writable: true,
0|Phi      |         allowHalfOpen: true,
0|Phi      |         destroyed: false,
0|Phi      |         _bytesDispatched: 0,
0|Phi      |         _sockname: null,
0|Phi      |         _pendingData: null,
0|Phi      |         _pendingEncoding: '',
0|Phi      |         server: [Object],
0|Phi      |         _server: [Object],
0|Phi      |         _idleTimeout: 120000,
0|Phi      |         _idleNext: [Object],
0|Phi      |         _idlePrev: [Object],
0|Phi      |         _idleStart: 22901,
0|Phi      |         parser: [Object],
0|Phi      |         on: [Function: socketOnWrap],
0|Phi      |         _paused: false,
0|Phi      |         read: [Function],
0|Phi      |         _consuming: true,
0|Phi      |         _httpMessage: [Circular] },
0|Phi      |      connection:
0|Phi      |       Socket {
0|Phi      |         connecting: false,
0|Phi      |         _hadError: false,
0|Phi      |         _handle: [Object],
0|Phi      |         _parent: null,
0|Phi      |         _host: null,
0|Phi      |         _readableState: [Object],
0|Phi      |         readable: true,
0|Phi      |         domain: null,
0|Phi      |         _events: [Object],
0|Phi      |         _eventsCount: 10,
0|Phi      |         _maxListeners: undefined,
0|Phi      |         _writableState: [Object],
0|Phi      |         writable: true,
0|Phi      |         allowHalfOpen: true,
0|Phi      |         destroyed: false,
0|Phi      |         _bytesDispatched: 0,
0|Phi      |         _sockname: null,
0|Phi      |         _pendingData: null,
0|Phi      |         _pendingEncoding: '',
0|Phi      |         server: [Object],
0|Phi      |         _server: [Object],
0|Phi      |         _idleTimeout: 120000,
0|Phi      |         _idleNext: [Object],
0|Phi      |         _idlePrev: [Object],
0|Phi      |         _idleStart: 22901,
0|Phi      |         parser: [Object],
0|Phi      |         on: [Function: socketOnWrap],
0|Phi      |         _paused: false,
0|Phi      |         read: [Function],
0|Phi      |         _consuming: true,
0|Phi      |         _httpMessage: [Circular] },
0|Phi      |      _header: null,
0|Phi      |      _headers: { 'x-powered-by': 'Express' },
0|Phi      |      _headerNames: { 'x-powered-by': 'X-Powered-By' },
0|Phi      |      _onPendingData: [Function: bound updateOutgoingData],
0|Phi      |      _sent100: false,
0|Phi      |      _expect_continue: false,
0|Phi      |      req: [Circular],
0|Phi      |      locals: {} } }

What am I doing wrong here?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
udaymscommented, Sep 19, 2017

Nevermind… I think I got the solution. @chimurai’s post on https://github.com/chimurai/http-proxy-middleware/issues/40 has an example that can do what I’m trying to do.

if (req.body) {
        let bodyData = JSON.stringify(req.body);
        // incase if content-type is application/x-www-form-urlencoded -> we need to change to application/json
        proxyReq.setHeader('Content-Type','application/json');
        proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));
        // stream the content
        proxyReq.write(bodyData);
    }
6reactions
chimuraicommented, Sep 16, 2017

This example uses the “body-parser” module in the main app to create a req.body object with the decoded POST parameters. Side note - the code below will allow “http-proxy-middleware” to work with “body-parser”.

You’ll need the body-parser middleware, as described.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring post method "Required request body is missing"
My issue was that, when I was making requests from Postman, the "Content-Length" header was unchecked, so service was not considering the ...
Read more >
req.body is empty in POST requests : r/node - Reddit
Hi! I know this is basically a noob question but please bear with me. I noticed that POST requests on my node server...
Read more >
Receiving "API request's body is either missing or incomplete ...
Hi, I am attempting to call the Creator API V2 Delete Records function from a CRM function and receiving the error "{"code":3020,"message":"API request's...
Read more >
Invalid or missing command in request body. - API V4
I have my own API for linking together several services used with mattermost utilising slash commands. I am looking to auto-detect when a...
Read more >
Request Body missing in Post call from Pre-request script - Help
I have a simple request that I want to send to my API. But before sending this request, I have to generate HMAC...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found