I use the npm subdomain and keep routing clean. I would like to do something like.
router.get('/login_success',function(req,res) { if(req.subdomain) { res.redirect('/'); } else { res.sendStatus(200); } });
In the above example, if a user logs into the application through a subdomain, I redirect him to the root subdomain that displays the profile.
If a user logs in via a non-subdomain route, he uses ajax to render the view, so I need to send a status of 200, saying that the user is valid.
I figured it was much cleaner that there are two separate callback routes for each.
So my question is, is there a way to determine if req came from a subdomain or a regular domain.
I know that there is req.headers.origin , but I wonder if there is a more relative way to do this, so when moving between the local and the production process, I do not need to change it.
source share