1
votes

I just started working with EmberJS again and encountered something that is giving me a few issues. I have a an index route and a show route defined like this.

this.route('sample-units', function() {
  this.route('show', {path: '/:id'});
});

I'm able to to load the index route with this url, http://localhost:4200/sample-units and am able to go to the show route using

{{#link-to 'sample-units.show' sampleUnit.id}}
  {{sampleUnit.id}}
{{/link-to}}

Which gives a url like so http://localhost:4200/sample-units/1344

The issue I'm experiencing is that any time I modify show.hbs, or refresh the page, Ember reloads and redirects me back to my index route instead of staying on the show page. I've worked with ember before and never had this issue, but that was back in 2.11. Has anyone encountered this before? I would assume that it would stay on the current route when I refresh the page, but for some reason it keeps leaving the show page and reloading on the index page. My show route is pretty basic and defined like so.

import Route from '@ember/routing/route';

export default Route.extend({
  model(params) {
    return this.get('store').findRecord('sample-unit', params.id);
  }
});

Does anyone know why this might be happening? Any help would be greatly appreciated.

1
How do you serve your app? Do you use ember s or something else?Gennady Dogaev
I use ember s to serve my app. That's why I thought it was strange since I was following the guides on routing from the main ember site.RKennedy9064
This might be some addon (ember-simple-auth, for example, can redirect if user is not authenticated) or some route has code to redirect (check all parent routes of sample-units.show starting from application)Gennady Dogaev
You may also check locationType in environment.js. Default value is auto and it should work fineGennady Dogaev

1 Answers

0
votes

Turns out that ember-simple-auth was the cause of the redirect. After configuring it correctly to work with the show route the redirect stopped.