Do the right tweak to this Node code (should be a very small tweak)

What you will do:

Minimum modifications to the following code to make it works.

See the bottom of this text.

Please, do not create a new code from scratch.

This code is almost fine, just need the right tweak.


$ npm i --save express http http-proxy-middleware

$ node [login to view URL]

file: [login to view URL]


var express = require('express');

var http = require('http');

var proxy = require('http-proxy-middleware');

function bodyTransform(body) {

body = [login to view URL]('is running', 'is now running');

body = [login to view URL]('3001', '3002');

return body;


var onProxyRes = (proxyRes, req, res) => {

const _writeHead = [login to view URL];

const _end = [login to view URL];

var buffer = new Buffer('');

let body = '';

[login to view URL]('data', (chunk) => {

[login to view URL]("inside: .on('data', ...)");

buffer = [login to view URL]([buffer, chunk]);


[login to view URL]('end', () => {

[login to view URL]("inside: .on('end', ...)");

body = [login to view URL]('utf8');


// defer writeHead

[login to view URL] = (...writeHeadArgs) => {

const output = bodyTransform(body);

if ([login to view URL] && [login to view URL]['content-length']) {

// if 'content-length' is set to: '[login to view URL]' it causes:

// ERR_CONTENT_LENGTH_MISMATCH (Google Chrome is explicit about the error)

// because it seems that the actual content output is an empty string (length: 0)

[login to view URL]('content-length', [login to view URL]);

[login to view URL]('assigned => content-length: ' + [login to view URL]);

// if the following line is uncommented, there are no errors

// because it seems that the actual content output is an empty string (length: 0)

// so the 'content-length' will match

// [login to view URL]('content-length', 0);


// disabling chunked encoding

[login to view URL]('transfer-encoding', '');

// disabling cache for all http as well

[login to view URL]('cache-control', 'no-cache');

[login to view URL](res, writeHeadArgs);


// defer all writes

[login to view URL] = (chunk) => { };

[login to view URL] = (...endArgs) => {

const output = bodyTransform(body);

if ([login to view URL]) {

[login to view URL](res, [output]);


else {

[login to view URL](res, endArgs);


[login to view URL]('after: [login to view URL](...);');



const portApp01 = 3001;

const app01 = express()

[login to view URL]('/', (req, res) => {

[login to view URL]('This server is running on port: 3001');


[login to view URL](portApp01, () => {

[login to view URL]('app01 is listening on port: ' + portApp01);


const portProxy = 3002;

const appProxy = express()

[login to view URL](proxy('/', { target: 'http://localhost:3001', onProxyRes: onProxyRes }));

[login to view URL](appProxy).listen(portProxy, function () {

[login to view URL]('appProxy is listening on port: ' + portProxy);



For initial test:

Go to the following url on the browser:


The browser outputs: 'This server is running on port: 3001'

Goal of your modification:

Do the minimal modifications to the code above in order to:

When going to the following url on the browser:


The browser should output: 'This server is now running on port: 3002'

There are some comments in the code that are explicit about the current issue of this code.

Taidot: Express JS, node.js

Näytä lisää: nodejs slow, heroku gzip node, node js faster, node js tricks, improve node js performance, node js express cache, node compression middleware, node compression filter, what is node.js, what is node, what is chrome extension, what is a chrome extension, what information do you need for a wire transfer, what is direct transfer?, what is direct transfer, chrome css errors, chrome extension match, check css errors chrome, check css errors chrome browser, magento chrome checkout ssl errors

Tietoa työnantajasta:
( 4 arvostelua ) Olathe, United States

Projektin tunnus: #17050704

7 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön


Hi, I am a NodeJS expert having 10 years of experience. I can start to work right away to complete it asap. Thanks

$111 USD 1 päivässä
(5 arvostelua)

Hey Sir, I am interested in your project.I am good in node.js and I can help you and I am ready to start the work right now, and will deliver with good result to you. please send me a message so that we can discuss Lisää

$25 USD 1 päivässä
(15 arvostelua)

Hi, I have almost 4 years of experience as nodejs developer, I saw your description I can help you on this, I need to clarify some queries, just ping me if you're ok, Thanks

$30 USD 1 päivässä
(4 arvostelua)

Hi nice to meet u I have good skills about nodejs Node js is very speed Node js is only thread processing server program if u hire me I will make good result see u again

$31 USD 0 päivässä
(0 arvostelua)
$27 USD 1 päivässä
(0 arvostelua)
$30 USD 1 päivässä
(0 arvostelua)
$15 USD 1 päivässä
(0 arvostelua)