withCredentials在Anuglar 5中不能使用HttpClient

时间:2018-02-19 12:15:40

标签: angular httpclient angular5

我想从Angular5项目向服务器发送http会话cookie 我发现我必须将withCredentials设置为true但它根本不起作用  这是HttpClient的拦截

  intercept(req: HttpRequest<any>, next: HttpHandler): 
       Observable<HttpEvent<any>> {
       req = req.clone({
         setHeaders: {
         Authorization: `Bearer ${localStorage.getItem('token')}`
             },
          withCredentials:true

         });

       return next.handle(req);
  }

0 个答案:

没有答案