可以通过配置 Angular 应用的 CORS 响应头和请求头来解决该问题。具体步骤如下:
示例(Node.js):
res.set('Access-Control-Allow-Origin', 'http://localhost:4200');
res.set('Access-Control-Allow-Credentials', 'true');
示例:
this.http.get('http://server.com/data', { withCredentials: true });
完成以上配置后,Angular 应用就能够在跨域请求时正确发送授权 cookie 了。