如何做流星铁路由器服务器端重定向



给定类似的东西

Router.route('/blah/:stuff', function () {
  // respond with a redirect
}, {where: 'server'});

如何进行重定向?里面有什么东西吗?还是我必须自己制作?

这是使用Meteor 1.0/Iron Router 1.0

在服务器路由中,您可以访问节点的response对象。举个例子,302重定向可能是这样的:

Router.route('/blah/:stuff', function () {
  var redirectUrl = 'http://example.org/' + this.params.stuff;
  this.response.writeHead(302, {
    'Location': redirectUrl
  });
  this.response.end();
}, {where: 'server'});

最新更新