Redirect on a different location and port in node.js

http, node.js, redirect

Solution

You need to specify the full URL:

res.writeHead(302, {
    Location: 'http://anotherdomain.com:8888/some/path'
});
res.end();

Problem

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.

Original source