简体   繁体   English

Wordpress API-Ionic GET-“ Access-Control-Allow-Origin”标头包含多个值“ *,*”

[英]Wordpress API - Ionic GET - The 'Access-Control-Allow-Origin' header contains multiple values '*, *'

am currently building some custom API's using WordPress API, and works great as calling from browser as this link: 目前正在使用WordPress API构建一些自定义API,并且可以很好地与浏览器调用,如下所示:

https://laundrylocker-eg.com/wp-json/wp/v2/delivery-locations https://laundrylocker-eg.com/wp-json/wp/v2/delivery-locations

response in JSON nothing goes wrong, so from Ionic application i try to call this api to get callback this data but faced this CORS Issue and try to fix it nothing works like disable CORS in chrome and using plugin enabling CORS for all domains as development phase JSON中的响应没有问题,因此从离子应用程序中,我尝试调用此api来获取此数据的回调,但遇到了CORS问题,并尝试解决此问题,例如在chrome中禁用CORS并使用插件为所有域启用CORS作为开发阶段

CORS PLUGIN IMG CORS PLUGIN IMG

CONSOLE ERROR 控制台错误

Failed to load https://laundrylocker-eg.com/wp-json/wp/v2/pickup-locations/2018-04-03 : Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. 无法加载https://laundrylocker-eg.com/wp-json/wp/v2/pickup-locations/2018-04-03 :对预检请求的响应未通过访问控制检查:'Access-Control-Allow -Origin'标头包含多个值'*,*',但只允许一个。 Origin ' http://localhost:8100 ' is therefore not allowed access. 因此,不允许访问源' http:// localhost:8100 '。 core.js:1350 ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: null, ok: false, …} core.js:1350错误HttpErrorResponse {标题:HttpHeaders,状态:0,statusText:“未知错误”,网址:null,确定:false,...}

REQUEST INFORMATION 要求信息

Request URL: https://laundrylocker-eg.com/wp-json/wp/v2/pickup-locations/2018-04-03 请求网址: https : //laundrylocker-eg.com/wp-json/wp/v2/pickup-locations/2018-04-03

Request Method: OPTIONS 请求方法:OPTIONS

Status Code: 200 OK 状态码:200 OK

Remote Address: 50.87.248.230:443 远程地址:50.87.248.230:443

Referrer Policy: no-referrer-when-downgrade 推荐人政策:降级时不推荐人

Access-Control-Allow-Credentials: true 访问控制允许凭据:true

Access-Control-Allow-Credentials: true 访问控制允许凭据:true

Access-Control-Allow-Headers: Authorization, Content-Type 访问控制允许标题:授权,内容类型

Access-Control-Allow-Headers: Authorization, Content-Type, Content-Range, 访问控制允许标题:授权,内容类型,内容范围,

Content-Disposition, Content-Description, Access-Control-Request-Method 内容配置,内容描述,访问控制请求方法

Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE 访问控制允许方法:POST,GET,OPTIONS,PUT,DELETE

Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS 访问控制允许方法:PUT,GET,POST,DELETE,OPTIONS

Access-Control-Allow-Origin: * 访问控制允许来源:*

Access-Control-Allow-Origin: * 访问控制允许来源:*

Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages 访问控制公开标头:X-WP-Total,X-WP-TotalPages

Allow: GET 允许:GET

Cache-Control: max-age=21600 快取控制:max-age = 21600

Connection: keep-alive 连接:保持活动状态

Content-Encoding: gzip 内容编码:gzip

Content-Length: 116 内容长度:116

Content-Type: application/json; 内容类型:application / json; charset=UTF-8 字符集= UTF-8

Date: Tue, 03 Apr 2018 12:02:28 GMT 日期:星期二,2018年4月3日12:02:28 GMT

Expires: Tue, 03 Apr 2018 18:02:28 GMT 过期:星期二,2018年4月3日18:02:28 GMT

Link: https://laundrylocker-eg.com/wp-json/ ; 链接: https//laundrylocker-eg.com/wp-json/ ; rel="https://api.w.org/" rel =“ https://api.w.org/”

Server: nginx/1.12.2 伺服器:nginx / 1.12.2

It's not that you are returning a single ACAO header with a value of *, * - it's that you are returning duplicate CORS headers, and the browser has merged them. 这并不是说您要返回一个*, **, * ACAO标头,而是要返回重复的CORS标头,并且浏览器已将它们合并。

Somewhere in your code (or in the code of the packages you're using), the CORS headers are being added twice. 在代码中的某个位置(或正在使用的软件包的代码中),CORS标头被添加了两次。 My guess is that you have somehow added two CORS-enablement packages or something like that, and they're both adding CORS response headers... 我的猜测是,您已经以某种方式添加了两个CORS启用包或类似的东西,并且它们都在添加CORS响应标头...

Since the value of the two Access-Control-Allow-Headers and Access-Control-Allow-Methods headers are different, it should be easy enough to search for where they are being added and remove the duplication. 由于两个Access-Control-Allow-HeadersAccess-Control-Allow-Methods头的值不同,因此应该很容易搜索要添加它们的位置并删除重复项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 修复'Access-Control-Allow-Origin'标头在NGINX中包含多个值错误 - Fixing the 'Access-Control-Allow-Origin' header contains multiple values error in NGINX WordPress 请求的资源上不存在“Access-Control-Allow-Origin”标头 - WordPress No 'Access-Control-Allow-Origin' header is present on the requested resource 使用angular + WordPress不存在“ Access-Control-Allow-Origin”标头 - No ‘Access-Control-Allow-Origin’ header is present using angular + WordPress 错误:没有“访问控制允许来源”header 存在 WordPress - ERROR: No 'Access-Control-Allow-Origin' header is present WordPress wordpress 中的访问控制允许来源 - Access-Control-Allow-Origin in wordpress Azure 上的 Wordpress 错误:被 CORS 策略阻止:请求的资源上不存在“Access-Control-Allow-Origin”标头 - Wordpress on Azure Error: Blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource WORDPRESS CORS 策略:请求的资源上不存在“Access-Control-Allow-Origin”标头 - WORDPRESS CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource 字体 url 上的“请求的资源上不存在‘Access-Control-Allow-Origin’标头”。 CloudFront 与 Lightsail Wordpress - "No 'Access-Control-Allow-Origin' header is present on the requested resource" on fonts urls. CloudFront with Lightsail Wordpress 被 CORS 政策阻止:没有“Access-Control-Allow-Origin”标头错误 - blocked by CORS policy: No 'Access-Control-Allow-Origin' header ERROR Phonegap 请求的资源上不存在“Access-Control-Allow-Origin”标头 - Phonegap No 'Access-Control-Allow-Origin' header is present on the requested resource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM