Safari 10.1:由于访问控制检查,无法加载带有查询参数的 XMLHttpRequest [英] Safari 10.1: XMLHttpRequest with query parameters cannot load due to access control checks

查看:24
本文介绍了Safari 10.1:由于访问控制检查,无法加载带有查询参数的 XMLHttpRequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Safari 10.1 上尝试 CORS 请求 时,在包含查询参数(例如 https://example.com/api?v=1),Safari 说

When trying a CORS request on Safari 10.1, on an URL which includes query parameters (e.g. https://example.com/api?v=1), Safari says

XMLHttpRequest 由于访问控制检查而无法加载

XMLHttpRequest cannot load due to access control checks

Chrome/Firefox 运行良好.

Chrome/Firefox works fine.

对于来自没有 ?v=1 的页面的请求,Safari 也可以正常工作.

On requests from the page without the ?v=1, Safari works fine too.

我尝试从

Access-Control-Allow-Origin: https://example.com

Access-Control-Allow-Origin: https://example.com/api?v=1

但这会破坏 Chrome.

but that breaks Chrome.

有什么建议吗?

推荐答案

如果有人遇到这个错误,它只是发生在我正在构建的应用程序中.就我而言,它原来是 uri 中的尾随/,导致 301 响应,出于某种原因,Safari 将其解释为 500 响应.

If anyone comes across this error, it just occurred in the application I was building. In my case, it turned out to be a trailing / in the uri, which caused a 301 response, which was for some reason interpreted by Safari as a 500 response.

这篇关于Safari 10.1:由于访问控制检查,无法加载带有查询参数的 XMLHttpRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆