How to switch to 404 route "just"?

I have a subdomain that is inside my pointing route. It looks for a plan for the subdomain and redirects it to the plan page. If the plan does not return, it needs to display a 404 page. Here is the code to redirect. I am admittedly new to ember, but this code seems to be correct. I get zero errors in the console, and it just goes to the route I'm trying to redirect from:

Controller /index.js

model: function() {
    var self = this;

    if ( this.isHomePage() ) {

      return Ember.Object.create();

    } else {

      // Get resources
      var parts = window.location.hostname.split('.');
      var subdomain = parts[0];

      return this.store.find('plan', { plan_subdomain: subdomain }).then(function(plans) {
        var returnedPlan = plans.get('firstObject');
        if (Ember.isEmpty(returnedPlan)){
          debugger;
          return self.transitionTo('fourOhFour');
        } else {
          return returnedPlan;
        }
      });

    }
  },

      

router.js

  this.route("fourOhFour", { path: "*path"});

      

+3


source to share


1 answer


You point your 404 path as a gimmick

this.route("fourOhFour", { path: "*path"});

      

which makes sense, but then you say Ember goes to this wildcard pattern, but what would the url be? /*

?



You need to tell Ember what this path should do by specifying the second parameter transitionTo()

See here for an example

I answered a similar question here

+3


source







All Articles