Node.js server doesn't receive html post requests


Hi, I’ve been learning Node.js using Express, I tried to make a simple HTML post request, that works on my local system, but doesn’t on Cloud9.

Heres my server.js:

var express = require(‘express’);
var app = express();
var bodyParser = require(‘body-parser’);

// Create application/x-www-form-urlencoded parser
var urlencodedParser = bodyParser.urlencoded({ extended: false })

app.get(’/index.htm’, function (req, res) {
res.sendFile( __dirname + “/” + “index.htm” );
})’/process_post’, urlencodedParser, function (req, res) {
// Prepare output in JSON format
response = {

var server = app.listen(process.env.PORT, process.env.IP, function () {
var host = server.address().address
var port = server.address().port

console.log(“Example app listening at https://%s:%s”, host, port)


  <form action = "https://$IP:$PORT/process_post" method = "POST">
     First Name: <input type = "text" name = "first_name"> <br>
     Last Name: <input type = "text" name = "last_name">
     <input type = "submit" value = "Submit">

I’ve already tried running it using http instead of https and my application url is public. When I run this code in my local system it works, when click “submit” I go to the “process_post” page and “first_name” and “last_name” are printed on the console, but when run on cloud9 I get an “about:blank” page and nothing on the console.


is $IP:$PORT in action url, your actual code? I think you need to write the url there
Also what errors do you see in browser console?


Hi, I tried changing “$IP:$PORT” to “”, now instead of a blank page I get sent back to when I click submit. No console errors or messages at all.


i believe you need to use action="" or yet better just action=/process_post"


It worked, thank you very much!