Angular 2 doesn't save my Authentication Cookie with CORS

前端 未结 2 782
野的像风
野的像风 2021-01-14 22:41

I have an angular 2 app which should authenticate to a Node Express backend where it sends an login request to the backend and receives a cookie. It should send this cookie

2条回答
  •  有刺的猬
    2021-01-14 23:32

    By default angular is not sending cookies. Try pass { withCredentials: true } to your RequestOptions:

    let options = new RequestOptions({ headers: headers, withCredentials: true });
    this.http.post(this.connectUrl,  , options);
    

提交回复
热议问题