Angular 跨域
Angular 跨域
https://github.com/angular/an...假如待请求的接口服务器为 https://xxx.xxxxxxx.com/api/c...
项目根目录
proxy.config.json
target 为接口服务器
{ "/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":"[email protected]","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', [])) ); } }
相关推荐
QiaoranC 2020-09-25
颤抖吧腿子 2020-09-04
liduote 2020-06-16
阿斌Elements 2020-06-11
xxuncle 2020-06-05
ChinaGuanq 2020-06-05
wanghongsha 2020-03-26
csm0 2020-03-05
shyoushine 2020-02-25
electronvolt 2020-02-12
jsonwoo 2020-01-20
ZadarrienChina 2020-01-07
wwwxuewen 2020-01-04
dynsxyc 2020-01-03
liangjielaoshi 2019-12-27
bowean 2019-12-27
wwwxuewen 2019-12-25
liwusen 2019-12-16
颤抖吧腿子 2019-12-16