WKWebView not making CORS OPTIONS requests

Number:rdar://41101647 Date Originated:13-Jun-2018 14:24
Status:Duplicate/39987152 -- Closed Resolved:
Product:iOS + SDK Product Version:12.0 beta 1
Classification:Serious Bug Reproducible:Always
In iOS 12.0 beta 1, cross origin requests are failing in WKWebView with the error “Preflight response is not successful”, but I cannot see any preflight requests being attempted via the Safari Web Inspector.

Steps to Reproduce:
Make a fetch call from a page running inside WKWebView

Expected Results:
An OPTIONS request should be made to the server, followed by the actual request (if the OPTIONS request was successful).
Both requests should be listed in the Network tab of the Safari Web Inspector.

Actual Results:
No OPTIONS request appears to be made.
An error is logged to the Safari console: “Preflight response is not successful. fetch cannot load [url omitted] due to access control checks.”

12.0 beta 1

See also rdar://40807782 and possibly rdar://40495434 (https://bugs.webkit.org/show_bug.cgi?id=186312)



This appears to be fixed in iOS 12 beta 2


Further testing has shown that this apparently only happens if you try to add/set HTTP headers when calling fetch (or XMLHttpRequest, which is also affected).

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!