参考:
angular2 services - angular 2 http withCredentials - Stack Overflow
结论:
1.可以在http请求时添加options
2.可以在拦截器统一对http请求进行封装
export class CustomHttpInterceptor implements HttpInterceptor {
constructor() {}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
request = request.clone({
withCredentials: true
});
return next.handle(request);
}
}