Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7680699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:10:30+00:00 2026-05-31T18:10:30+00:00

I do not get the last version of node-http-proxy working (this used to work

  • 0

I do not get the last version of node-http-proxy working (this used to work in a previous version though). Node.js version is 0.6.12, node-http-proxy version is 0.8.0.
Basically, I have a server listening on port 10000 and another one listening on port 5000. I ‘d like to proxy to this last guy all the requests starting with /api (after having removed this prefix).

My code is:

var express = require("express");
var httpProxy = require('http-proxy');
var cluster = require('cluster');
var fs = require('fs');

// Use http server for local tests
var app = express.createServer();

// Proxy request targeting API
app.all('/api/*',function(req, res){

  // Remove '/api' part from query string
  req.url = '/' + req.url.split('/').slice(2).join('/');

  // Create proxy
  var proxy = new httpProxy.HttpProxy();
  proxy.proxyRequest(req, res, {
    target: {
      host: 'localhost',
      port: 5000
    }
  });
});

// Handle static files
app.use(express.static(__dirname + '/public'));

// Run application
app.listen(10000);

The static files are correctly served but when it comes to the proxy stuff, I got this error:

Error: Both `options` and `options.target` are required.
at new <anonymous> (/Users/luc/Projects/test/www/node_modules/http-proxy/lib/node-http-proxy/http-proxy.js:53:11)
at /Users/luc/Projects/test/www/server.js:15:16
at callbacks (/Users/luc/Projects/test/www/node_modules/express/lib/router/index.js:272:11)
at param (/Users/luc/Projects/test/www/node_modules/express/lib/router/index.js:246:11)
at pass (/Users/luc/Projects/test/www/node_modules/express/lib/router/index.js:253:5)
at Router._dispatch (/Users/luc/Projects/test/www/node_modules/express/lib/router/index.js:280:4)
at Object.handle (/Users/luc/Projects/test/www/node_modules/express/lib/router/index.js:45:10)
at next (/Users/luc/Projects/test/www/node_modules/express/node_modules/connect/lib/http.js:203:15)
at Object.handle (/Users/luc/Projects/test/www/node_modules/express/lib/http.js:83:5)
at next (/Users/luc/Projects/test/www/node_modules/express/node_modules/connect/lib/http.js:203:15)-error-undefined

I’ve added the target as requested but still the same error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:10:32+00:00Added an answer on May 31, 2026 at 6:10 pm

    You need to pass your options to the HttpProxy constructor function, not to the proxyRequest function.

    https://github.com/nodejitsu/node-http-proxy/blob/master/lib/node-http-proxy/http-proxy.js#L51

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how to get the status (200 OK, 404 NOT FOUND etc.) of the last
I can not get to make this comparison in this simple code error ..
Did I not get enough sleep or what? This following code var frame=document.getElementById(viewer); frame.width=100;
It seems to not get past this step: [ 16%] Building CXX object src/CMakeFiles/hphp_runtime_static.dir/lib/system/gen/sys/dynamic_table_func.no.cpp.o
I asked a similar question last week but did not get an answer that
I found that GCCXML is not being maintained anymore (I think the last version
It is not related to whatever version it is, just working to find out
I simply can not get Visual Studio 2005 to find the System.Configuration.ConfigurationManager class. Here
I can not get logs from some customers, can I use Google Urchin in
I can not get environment at custom target shell. CMakeList.txt set( ENV{TEST_VAR} Hello )

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.