Reputation: 3284
I'm preparing a demo of my new ember app, temporarily deploying it to a static http server, without a proper backend.
I've configured the project to fetch its data from mirage, and it works nicely locally.
The problem is that when I upload it to my http server, the mirage doesn't seem to be working, and the demo raises:
vendor-1bce2a3….js:11 Error while processing route: activities Ember Data Request GET /activities returned a 404
Payload (text/html)
[Omitted Lengthy HTML] Error: Ember Data Request GET /activities returned a 404
Payload (text/html)
[Omitted Lengthy HTML]
at new Error (native)
at Error.r (http://www.my-domain.com/myproject/assets/vendor-1bce2a36ef171f16e76daffe157c9b37.js:8:14790)
at Error.n (http://www.my-domain.com/myproject/assets/vendor-1bce2a36ef171f16e76daffe157c9b37.js:19:25963)
at e.default.r.default.extend.handleResponse (http://www.my-domain.com/myproject/assets/vendor-1bce2a36ef171f16e76daffe157c9b37.js:22:29329)
at c.error (http://www.my-domain.com/myproject/assets/vendor-1bce2a36ef171f16e76daffe157c9b37.js:22:29898)
at u (http://www.my-domain.com/myproject/assets/vendor-1bce2a36ef171f16e76daffe157c9b37.js:2:9669)
at Object.c.fireWith (http://www.my-domain.com/myproject/assets/vendor-1bce2a36ef171f16e76daffe157c9b37.js:2:10437)
at n (http://www.my-domain.com/myproject/assets/vendor-1bce2a36ef171f16e76daffe157c9b37.js:3:13352)
at XMLHttpRequest.<anonymous> (http://www.my-domain.com/myproject/assets/vendor-1bce2a36ef171f16e76daffe157c9b37.js:3:19180)
this is my configuration of mirage:
// app/mirage/config.js
export default function() {
this.get('/activities', function(db, request) {
return { 'activity': db.activity };
});
this.get('/activities/:id', function(db, request) {
var id = request.params.id;
return { 'activity': db.activity.find(id) };
});
}
it works find on my local machine, but it won't work on the http server, any ideas on how to get the demo to work?
Thanks,
Upvotes: 0
Views: 355
Reputation: 2811
Since you said you can use PHP you're likely using Apache and will need to change how it handles requests to work with html5 pushState ... If you don't already have an .htaccess
file in your /myproject
directory, create it and have it contain:
FallbackResource /myproject/index.html
This will have Apache pass along any requests for things that don't exist (and normally would result in a 404) to the path specified ...
Upvotes: 0
Reputation: 12694
By default, Mirage is disabled in production
builds. You can enable it with the ENV option:
// app/config/environment.js
...
if (environment === 'production') {
ENV['ember-cli-mirage'] = {
enabled: true
}
}
See the docs for more info: http://www.ember-cli-mirage.com/docs/v0.1.x/server-configuration/#enabled
Upvotes: 2