首页 > 解决方案 > 从源“http://localhost”访问“https://xxxxxxxxx”处的 XMLHttpRequest 已被阻止 angular 11

问题描述

从源“http://localhost”访问“https://xxxxxxxxx”处的 XMLHttpRequest 已被 CORS 策略阻止:请求的资源上不存在“Access-Control-Allow-Origin”标头。我的代码: const headers = new HttpHeaders().set( 'Content-Type', 'application/x-www-form-urlencoded;' ).set('Access-Control-Allow-Origin', '*');

返回 this.http.post(this.rootURL +'/connect/token', body ,{ 'headers': this.headers })

在生产中使用它

标签: apiangular11

解决方案


推荐阅读