Safe redirect middleware for connect.