如何修复 iOS 12 Safari Cors 预检错误? [英] How to fix iOS 12 Safari Cors preflight error?

查看:33
本文介绍了如何修复 iOS 12 Safari Cors 预检错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更好地理解 COR,因为我们的网络应用程序的一些用户在升级到 iOS 12 后抱怨他们收到了预检错误.

I am trying to understand CORs a little better as several users of our web app are complaining since they upgraded to iOS 12 they are receiving preflight errors.

来自网络检查器的错误

[Error] Preflight response is not successful
[Error] Fetch API cannot load https://www.api.com due to access control checks.
[Error] Failed to load resource: Preflight response is not successful (v4, line 0)

客户端应用程序是一个带有 Apollo 的 React 应用程序.它使用 Apache HTTPD 和 Express JS 通过 HTTPS 调用服务器.

The client app is a React app with Apollo. It calls a server over HTTPS with Apache HTTPD and Express JS.

在所有其他浏览器上一切正常,这与 iOS 12 隔离.

Everything works fine on all other browsers, this is isolated to iOS 12.

奇怪的是,当我查看 HTTPD 访问日志时,我看不到任何预检调用.当我尝试直接访问服务器(在 iOS 12 上)时,我在日志中看到了预检选项请求和 POST.但是当通过 Web 应用调用服务器时,CORs 预检失败.

Whats weird is when I look through the HTTPD access logs, I can't see any preflight calls. When I try hit the server directly (on iOS 12), I see both the preflight OPTIONS request and POST in the logs. But when calling the server through the web app, the CORs preflight fails.

在 express 应用中,我也注销了所有请求,它也没有出现在那里.

In the express app, I also logged out all requests, and it doesn't appear there either.

在 HTTPD 中我有

In HTTPD I have the settings of

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS

在快递中我也有同样的事情.

In express I have the same thing.

有什么想法吗?!

推荐答案

过去两天我一直在与这个完全相同的问题作斗争,现在才找到解决方案/答案.

I've been fighting with this exact same issue for the last two days and just now found the solution/answer.

这是 iOSv12 中的一个错误,但它已在 iOSv12.1 beta (16B5059d) 中修复,假设当前的 beta 代码已投入生产.

It's a bug in iOSv12, but it's already fixed in iOSv12.1 beta (16B5059d), assuming the current beta code makes it into production.

问题在于 iOSv12 WebKit 预检 OPTIONS 调用不会离开设备.我已经运行 WireShark 和 iOSv12 模拟器来确认这一点.

The problem is that iOSv12 WebKit preflight OPTIONS calls don't leave the device. I've run WireShark and the iOSv12 simulator to confirm this.

长期潜伏者,我注册了一个帐户来发布这个答案.如果我的回答违反了规则/礼仪,我很抱歉.

Long time lurker, I made an account just to post this answer. If I broke rules/etiquette with this answer, I'm sorry.

这篇关于如何修复 iOS 12 Safari Cors 预检错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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