How to pass through `ember-cli-mirage` request to a specific API and Host

1.7k views Asked by At

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.

1

There are 1 answers

2
jkubaile On

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/