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 6575129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:20:57+00:00 2026-05-25T15:20:57+00:00

I have the following in my node server using Express (truncated to the important

  • 0

I have the following in my node server using Express (truncated to the important parts):

var app = express.createServer();

app.all(/test/,function(req,res){
    console.log(req.headers);
    console.log(req.body);
    res.send("");
});

function appStart(cobrands){
    app.configure(function(){
        app.use(express.bodyParser());
        app.use(express.cookieParser());

        app.use('/min',express.static('../min'));
        app.use('/js',express.static('../js'));
        app.use('/css',express.static('../css'));
        app.use('/img',express.static('../img'));
    });
    app.listen(8080);
}

I then have a simple form that calls out to localhost:8080 like so:

<form action="http://localhost:8080/test" method="post">
    <input type="hidden" name="test" value="testing"/>
    <input type="submit" name="submit" value="to node"/>
</form>

But express.bodyParser doesn’t seem to be doing anything, and req.body is undefined. Here’s the output of the console.logs:

// req.headers
{ host: 'localhost:8080',
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/534.48.3 (KHTML, like Gecko) Version/5.1 Safari/534.48.3',
  'content-length': '27',
  accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  origin: 'file://',
  'content-type': 'application/x-www-form-urlencoded',
  'accept-language': 'en-us',
  'accept-encoding': 'gzip, deflate',
  cookie: '',
  connection: 'keep-alive' }
// req.body
undefined

Note: content-type is correctly defined as application/x-www-form-urlencoded as it should be for bodyParser to work, and I’ve verified that it’s coming over by popping open the debug tools in Safari and verifying that the form data is present.

  • 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-25T15:20:58+00:00Added an answer on May 25, 2026 at 3:20 pm

    http://expressjs.com/guide.html#configuration

    Note the use of app.router, which can (optionally) be used to mount
    the application routes, otherwise the first call to app.get(),
    app.post(), etc will mount the routes.

    What’s happening is you’re calling app.all() before adding any of the other middleware. Doing this effectively puts app.router in front of all of your other middleware, resulting in them never being used on requests that end inside your routes.

    Mounting the application routes is pretty much the same as doing app.use(app.router);.

    In the end your stack is looks this:

    app.use(app.router); // Contains your /test/ route
    app.use(express.bodyParser());
    app.use(express.cookieParser());
    app.use('/min',express.static('../min'));
    app.use('/js',express.static('../js'));
    app.use('/css',express.static('../css'));
    app.use('/img',express.static('../img'));
    

    tl;dr Move your route between your call to app.configure() and app.listen().

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

Sidebar

Related Questions

I have the following simple http server using Node.js: var http = require('http'); var
I have a Node.js app using Express that stores data in a mongoDB (locally).
I have the following node.js server set up listening to port 9001 var https
I have the following XPATH line: //det[@nItem=1]/prod/cProd That successfully selects the desired node using
I am using socket.io to connect to my node server using the following script:
I have the following HTML node structure: <div id=foo> <div id=bar></div> <div id=baz> <div
I need to have following attribute value in my XML node: CommandLine=copy $(TargetPath) ..\..\&#x0D;&#x0A;echo
I have the following input: <node TEXT=txt> <node TEXT=txt> <node TEXT=txt/> <node TEXT=txt/> </node>
I have atleast 16 functions of the following form. bool Node::some_walker( Arg* arg1 )
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,

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.