Search code examples
javascriptember.jsember-cli-mirage

this.passthrough() functionality in Ember


I am writing an application in Ember.js and I am also using Ember mirage. I need to make requests to an external server and I am currently trying to set up my config.js file to deal with such requests. Adding this.passthrough() does not work and I still get an error when I try to make my request saying:

"Your Ember app tried to GET 'http://...' but there was no route defined to handle this request. Define a route that matches this path in your mirage/config.js file. Did you forget to add your namespace?

I believe this should be a simple thing to fix, any ideas of what is going wrong?


Solution

  • Mirage helpdoc explaining it detail. configuration/#passthrough

    If you want all requests on the current domain to pass through, simply invoke the method with no arguments:

    this.passthrough();
    

    You can also allow other-origin hosts to passthrough. If you use a fully-qualified domain name, the namespace property will be ignored. Use two * wildcards to match all requests under a path:

    this.passthrough('http://api.foo.bar/**');
    

    Note:Put all passthrough config at the bottom of your config.js file, to give your route handlers precedence.