@josiahbryan wrote:
TL;DR: Added custom location type to
environment.js
thenember serve
-> open browser to route /foo ->cannot GET /foo
Followed the instructions at https://www.emberjs.com/api/classes/Ember.Location.html#toc_custom-implementation and copied the code exactly as it appeared into a file called
app/locations/history-url-logging.js
, added a line toconfig/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
toember s
then didember s
again. I went back to my browser sitting on one of the routes, hitF5
, and received the cryptic error:
Cannot GET /contacts
So, after MUCH Googling and trial and error (and posting a previous question here which I just edited with this text you're reading), 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 saysENV.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]
Posts: 1
Participants: 1