3
votes

In Node Js route.js when user try to open

app.use('/mysite1', require('express').static(__dirname + '/mysite1'));

then I want to redirect to

app.use('/mysite2', require('express').static(__dirname + '/mysite2'));

Both paths belong to two different origins.

like In the browser user type http://locahhost:5009/mysite1 this URL

but it will open http://locahhost:5011/mysite2 this URL

1
app.use('/mysite1', function(req, res, next){ res.redirect('http://locahhost:5011/mysite2'); });Mukesh Sharma

1 Answers

1
votes

Redirecting to a different origin requires nothing special. You just put the URL in the response as normal.

res.redirect('http://locahhost:5011/mysite2');

Obviously you need to have a route to handle the original URL which runs that code instead of using the static plugin. You aren't serving a static file for the original URL any more.