开发者

Route client to external site in node.js?

开发者 https://www.devze.com 2023-03-21 19:42 出处:网络
This may be stupadly easy, or just impossible - but it\'s worth asking in my opinion. The reason is because I was trying to demo a quick and dirty (lol) url-shortening app.

This may be stupadly easy, or just impossible - but it's worth asking in my opinion.

The reason is because I was trying to demo a quick and dirty (lol) url-shortening app.

app.get('/link/:key', function(req, res){
  client.get(req.params.key, f开发者_C百科unction(err, reply){
    if(client.get(reply)){
      // route to reply here
    }
    else{
      res.render('index', {
        link: null
      });
    }
  });
});

How would I perform that route, if possible?


http://expressjs.com/guide.html:

res.redirect('/', 301);
res.redirect('/account');
res.redirect('http://google.com');
res.redirect('home');
res.redirect('back');
0

精彩评论

暂无评论...
验证码 换一张
取 消