Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect on a different location and port in node.js

To redirect a user to a different page, we usually do:

res.writeHead(302, {
    Location: '/test'
});
res.end();

What if I want to redirect him on a different port? I tried to add a field 'Port' but it seems to don t work.

like image 643
DrakaSAN Avatar asked Feb 06 '14 13:02

DrakaSAN


1 Answers

You need to specify the full URL:

res.writeHead(302, {
    Location: 'http://anotherdomain.com:8888/some/path'
});
res.end();
like image 105
TheHippo Avatar answered Sep 24 '22 22:09

TheHippo