Reputation: 1419
what Im doing wrong in the below code
var path = 'http://' + someip + ':' + port ;
//var path = "http://someip:1000/"; // This is working
res.writeHead(302, {'Location': path});
Any help on this will be really helpful.
Upvotes: 0
Views: 56
Reputation: 320
It's difficult to understand your problem just by two lines, you might be doing other things wrong. This should be what you looking for.
var express = require('express');
var app = express();
var someip = '127.0.0.1';
var port = '8080';
app.get('/hello.txt', function(req, res){
var path = 'http://' + someip + ':' + port ;
body = 'Redirecting to ' + path;
res.writeHead(302, {'Location': path, 'Content-Type': 'text/html'});
res.end(body);
});
app.listen(3000);
Upvotes: 2