1

我正在尝试使用passthrough的功能ember-cli-mirage允许我的应用程序请求不同的 API 和主机。

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';

};

我想将请求指向当前 ember 服务器正在运行的环境之外。但是通过固定 URL 的请求就像/api/authenticate.

它抛出异常如下。

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

我想将请求配置为如下所示

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

ember-cli-mirage/伪装者中是否有任何可用选项?请帮忙。

4

1 回答 1

1

穿越是正确的。只需提供完整的 url 作为参数,例如:

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

看看这里的 twitter 示例:http ://www.ember-cli-mirage.com/docs/v0.2.x/route-handlers/

于 2016-11-04T06:55:09.763 回答