1

I am trying to use passthrough feature of ember-cli-mirage to allow my app to request to different API and Host.

export default function() {
  //window.server = this;
  //this.namespace = 'api';
  this.passthrough('locales/en/translation.json');
  this.get('/api/customers');
    this.passthrough();
  this.host='https://abcd.site.com';//need something like this, but not working
  this.namespace = 'api/Service.svc';

};

I want to point the requests to outside of the environment where current ember server is running. But the requests which are passing through fixed URL's like /api/authenticate.

It is throwing exceptions as follows.

POST http://localhost:4200/api/authenticate 404 (Not Found)

I want configure the requests to something like this below

https://abcd.site.com/api/Service.svc/authenticate

Is there any option available in ember-cli-mirage/ pretender? Please help.

amesh
  • 1,311
  • 3
  • 21
  • 51
  • I believe you're looking for a http-proxy, Mirage/Pretender cannot proxy actual HTTP requests as it is just an interceptor that lives in JavaScript memory. Check Ember CLI docs for the http proxy. – Sam Selikoff Nov 03 '16 at 17:15

1 Answers1

1

Passthrough is correct. Just give the full url as parameter, like:

this.passthrough('https://abcd.site.com/api/Service.svc/authenticate');

Take a look at the twitter example here: http://www.ember-cli-mirage.com/docs/v0.2.x/route-handlers/

jkubaile
  • 91
  • 3
  • This approach will work. But the issue is I have a huge number of API calls like this. This will force me to add `passthrough` forall these requests. Basically I need to use `ember-cli-mirage` to server few requests. The rest of requests need to `passthrough` to the network layer – amesh Nov 04 '16 at 11:02
  • Passthrough also accepts Wildcards, maybe this helps? – jkubaile Nov 04 '16 at 17:49