Simple 301 redirect in Meteor?


I’m looking for a simple example of a 301 redirect in Meteor.

For example: I want to 301 redirect to

I’m using FlowRouter if that’s at all relevant.


Here is a piece of server-side code from our app for you to customize

    WebApp.connectHandlers.use(function(req, res, next) {
      var path = req._parsedUrl.path;
      // console.log(req);
      if (path == "/") {
        // temporary redirect -
        res.writeHead(307, {Location: '/landing'});
      else next.apply();


@ramez is right, as that’s the only way to get a response code, and also saves you from flicker when you refresh the page or arrive to the route from an external site. FlowRouter only works in the frontend.

However, for a smooth user experience, you should also ensure frontend redirection from ‘/foo’ to ‘/bar’. More info here:

Here is an excellent resource, highlighting how server-side routing can work hand in hand with client-side routing: