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

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

问题描述

由于我们的Web应用程序的多个用户抱怨,因为他们已升级到iOS 12,因此他们收到预检错误,因此我试图更好地理解COR.

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上),我在日志中看到预检OPTIONS请求和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.

在快速应用中,我也注销了所有请求,但它也没有出现.

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中的错误,但假设当前的Beta代码已投入生产,则它已在iOSv12.1 beta(16B5059d)中修复.

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天全站免登陆