Reputation: 439
I'm unsure of how to word this, sorry if its not straight forward.
When a user enter www.example.com in the browser address bar or an ip of my server running node.js I would like to get the incoming request and decide what to do from there:
var express = require('express');
var app = express();
app.get('/', function(req, res){
var target=app.get('host');
console.log(target);
});
app.listen(8088,"0.0.0.0");
As a result I'm seeing 'undefined' printed on the console, rather than what was entered in the browser as I expected. What am I doing incorrectly?
Upvotes: 0
Views: 1782
Reputation: 18956
app.get('/', function(req, res){
// print host
console.log(req.headers.host);
// print path and request parameters
console.log(req.url);
res.end();
});
Upvotes: 5