[英]How to pass through `ember-cli-mirage` request to a specific API and Host
I am trying to use passthrough
feature of ember-cli-mirage
to allow my app to request to different API and Host. 我正在尝试使用ember-cli-mirage
passthrough
功能,以允许我的应用请求不同的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';
};
I want to point the requests to outside of the environment where current ember server is running. 我想将请求指向运行当前ember服务器的环境之外。 But the requests which are passing through fixed URL's like /api/authenticate
. 但是通过固定URL传递的请求如/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? ember-cli-mirage / pretender中是否有任何选项? Please help. 请帮忙。
Passthrough is correct. 直通是正确的。 Just give the full url as parameter, like: 只需提供完整的url作为参数,例如:
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/ 在这里查看Twitter示例: http : //www.ember-cli-mirage.com/docs/v0.2.x/route-handlers/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.