【问题标题】:Route client to external site in node.js?将客户端路由到 node.js 中的外部站点?
【发布时间】:2011-10-09 01:56:59
【问题描述】:

这可能非常简单,或者根本不可能——但在我看来,这是值得一问的。

原因是因为我试图演示一个快速而肮脏(笑)的网址缩短应用程序。

app.get('/link/:key', function(req, res){
  client.get(req.params.key, function(err, reply){
    if(client.get(reply)){
      // route to reply here
    }
    else{
      res.render('index', {
        link: null
      });
    }
  });
});

如果可能,我将如何执行该路线?

【问题讨论】:

    标签: http url redirect node.js


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2011-03-24
      • 1970-01-01
      • 2015-12-06
      • 2016-12-31
      • 2018-05-19
      • 2018-12-29
      • 2013-08-10
      • 2015-06-23
      • 2020-07-10
      相关资源
      最近更新 更多