WKWebView CORS Issue

Hi,

We are having a problem by getting an empty POST data on our API.
We are loading our application using WKWebKit. Inside our application, it sends a POST request to the third-party API with a data that has Content-Type: application/x-www-form-urlencoded.
Code Block javascript $.ajax({        method'POST',        url: thirdpartyURL + '/getData',        data'params=' + JSON.stringify(params),        successfunction (e) {          console.log(e)		})}


We've also added the necessary headers in the third-party application for CORS:
Code Block php$response->header('Access-Control-Allow-Origin''*');$response->header('Access-Control-Allow-Methods''GET, POST, PUT, DELETE, OPTIONS');

It was reflected in headers during the request as well as the params data from the AJAX request.

However, upon checking the request data in the third-party API, we found out that it was empty.

We are also encountering an error log of:
Origin myapplicationURL is not allowed by Access-Control-Allow-Origin.

We are not encountering this error in IOS Safari. Was there anything we might have missed?

Is your app Cordova-based?
There is an article related to CORS problems in WKWebView, but this forum does not allow me to include URL to it. So you can find it yourself at breautek.com, it it the only one published there.

TL;DR:
Setting 'Access-Control-Allow-Origin' to '*' is not enough, you should set it to the same value as the request 'Origin' header.

WKWebView CORS Issue
 
 
Q