无法通过angular2 web应用程序在发布请求中发送cookie

我正在同一个实例上运行两个不同的服务器,端口号不同,一个是节点(前端),另一个是tomcat(后端)。

示例: http:// localhost:4021是节点服务器(Angular2 Web应用程序), http:// localhost:8090是tomcat服务器(Java)

我能够在登录前从8090获取数据没有问题,但是当我登录时,2个cookie将通过后端设置到浏览器中。 每当我们对任何数据提出任何请求时,浏览器必须每次向请求标头中的服务器发送这两个cookie,但它们不会被发送。

我尝试在请求选项中发送“withCredentials:true”,但没有奏效。

let headersDefult = new Headers({'Content-Type':'application/json;charset=UTF-8'}); let requestOptions = new RequestOptions({ headers: headersDefult, withCredentials: true }); httpPOST(link, payload): Observable { let url = 'http://localhost:8090/'; let self = this; return this.http.post(url, payload, requestOptions) .map(this.extractData) .catch(this.handleError); }