I am having trouble using res.redirect() in express.
I have tried looking on other questions but the answers don't really cover my specific problem, or they at least aren't relevant enough.
app.get(/\d\w*/g, function (req, res, next) {
urlCreator.findURL(req.originalUrl,function(smallURL){
if (smallURL === "Small URL doesn't exist"){
res.send(smallURL);
}
else {
res.redirect(smallURL);
}
});
});
When the res.redirect() within the else block gets reached, I get this in my browser (screenshot below) instead of redirecting to whatever the page desired. The format of smallUrl is for example "www.facebook.com"
Am i missing something obvious as to why the browser will not simply redirect and displays this instead?
via tophergd
No comments:
Post a Comment