脚本宝典收集整理的这篇文章主要介绍了Angular 跨域,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
Angular 跨域
https://github.com/angular/an...假如待请求的接口服务器为 https://xxx.xxxxxxx.com/api/c...
{
"/api": {
"target": "https://xxx.xxx.COM/api",
"changeOrigin": true,
"secure": false,
"LOGLevel": "debug",
"pathrewrITe": {
"^/api": ""
}
}
}
export class AuthenticationService implements AuthService {
API_URL = '/api/';
API_ENDPOINT_LOGIN = 'card/Login';
public login(credential: Credential): Observable<any> {
// Expecting response From API
// tslint:disable-next-line:max-line-length
// {"id":1,"username":"admin","password":"demo","email":"admin@demo.com","accessToken":"access-token-0.022563452858263444","refreshToken":"access-token-0.9348573301432961","roles":["ADMIN"],"pic":"./assets/app/media/img/users/user4.jpg","fullname":"Mark Andre"}
return this.http.get<AccessData>(this.API_URL + this.API_ENDPOINT_LOGIN + '?' + this.util.urlParam(credential)).pipe(
map((result: any) => {
if (result instanceof Array) {
return result.pop();
}
return result;
}),
tap(this.saveAccessData.bind(this)),
catchError(this.handleError('login', []))
);
}
}
以上是脚本宝典为你收集整理的Angular 跨域全部内容,希望文章能够帮你解决Angular 跨域所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。