api - 从源“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 })
在生产中使用它
解决方案
推荐阅读
- laravel - 如何在 Laravel 5.7 中将默认身份验证“守卫”添加到身份验证和配置?
- c# - 在android设备中定位图像的文件路径
- javascript - 如何在 redux-form 中禁用提交按钮
- regex - 如何用不在数字之间的斜线分割字符串?
- oracle - Oracle 数据库创建
- python - 当他们在不同的模型上填写表单时更新 Django 中的用户模型
- mysql - 显示员工的销售额
- regex - 正则表达式:yaml 查找匹配
- cognos-bi - 在交叉表中编辑“无价值” - Cognos Analytics 仪表板
- php - 通过 PHP 将 XML 转换为 CSV - 如何获取属性值?