I have an Ember with a redirect from the index route that looks like this:
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel: function() {
this.transitionTo('dashboard');
},
});
This works great whenever I click on a link in my Ember app that goes to index: clicking on browser’s Back button takes me back to the previous route, as expected.
However, upon initial load of the root route (e.g. myemberapp.com/), both the root and /dashboard remain in the browser history, breaking the Back button. I have to click and hold on the Back button and skip the root to really go back to where I was before.
Tested in a new ember-cli project transitioning from
“localhost:8000/tests” --(typing in url)–> “localhost:8000/” —beforeModel–> “localhost:8000/dashboard” --(back button)-> “localhost:8000/tests”
That fixes the initial load but breaks internal transitions.
That is, once the Ember application is loaded and you navigate to multiple routes via internal links, say, /foo -> /bar -> / -(redirected to)-> /dashboard, if you now go back, you’ll end up at /foo because replaceWith has erased /bar from the history.