TL;DR: Added custom location type to environment.js
then ember serve
→ open browser to route /foo → cannot GET /foo
Followed the instructions at Location - 4.6 - Ember API Documentation and copied the code exactly as it appeared into a file called app/locations/history-url-logging.js
, added a line to config/environment.js
that said:
ENV.locationType = 'history-url-logging';
For reference, the code given in the docs is simply:
import Ember from 'ember';
export default Ember.HistoryLocation.extend({
implementation: 'history-url-logging',
pushState: function (path) {
console.log(path);
this._super.apply(this, arguments);
}
});
I decided to restart the server, did the usual CTRL+C
to ember s
then did ember s
again. I went back to my browser sitting on one of the routes, hit F5
, and received the cryptic error:
Cannot GET /contacts
So, after MUCH Googling and trial and error, I discovered that to FIX that error, all I had to do remove the config line ENV.locationType = 'history-url-logging';
, restart the server (ember s
), and suddenly the app worked fine!
What’s even more odd is that if I start the app without that line in environment.js
, then once the app is running (and the browser window reloads just fine, etc), then I re-add the line that says ENV.locationType = 'history-url-logging';
(which triggers a live reload), and the app still works fine! (E.g. hitting F5 to reload the page doesn’t vie me the “Cannot GET /contacts” (or whatever the route is) error.) And, of course, the console gives me the “console.log” output as expected from the code above.
So, long and short of it, using a custom location totally seems to screw up ember serve
- which is really sad and frustrating! Any ideas how to fix this?
[Full disclosure: Posted on SO #44223927 with no resolution]