Not able to set Origin in request header for iOS 12

We have made some changes at back end and due to that we need to send some app specific values for Origin of request header. In case of iOS 12 this value is getting replace by some defualt value as file://


ApleWebKit version is 605.1.15

Replies

What API are you using?

NSURLSession
? Or a web view? And if it’s the latter, which web view (
WKWebView
,
UIWebView
,
SFSafariViewController
)?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

AppleWebkit version is 605.1.15. Problem is when I am setting Origin to some specific values like "xyz", I am able to see the valued in sarafri develioper tools but in case of iOS 12 it's again getting replaced by "Origin:file://"

You wrote:

I wrote:

What API are you using?

AppleWebkit version is 605.1.15.


WebKit is not an API on Apple platforms. Rather, WebKit is an open source library that Apple uses to implement various apps (like Safari) and APIs (like

WKWebView
).

What API are you using? Or are you doing this in Safari itself?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Below is the result of iOS11 and 12


iOS 12


Summary

URL: xyz.com

Status: 403 Forbidden

Source: Network


Request

Accept: application/javascript, application/json

Cache-Control: max-age=7200, must-revalidate, private

Pragma: max-age=7200, must-revalidate, private

Content-Type: application/json

Origin: file://. // This is creating problem






iOS 11


Summary

URL: xyz.com

Status: 200 OK

Source: Network



Request

Content-Type: application/json

Origin: getting proper value

Pragma: max-age=7200, must-revalidate, private

I am using NSURLConnection API.

I am using

NSURLConnection
API.

Thanks for clarifying that.

btw Be aware that

NSURLConnection
has been deprecate for many years now. It’s definitely time to make the jump to
NSURLSession
[1].
Origin: file://.
// This is creating problem
NSURLConnection
does not set the
Origin
header directly. Something in your code must be setting that on the
NSURLRequest
used to start the connection. Can you post that code snippet?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

[1] Although that’s unlikely to affect this problem because they both share the same core HTTP[S] code.

It's not a native app, it's a hybrid app/ We are using cordova and internally it's starting connection. Below is the code responsible for setting request header.



options.headers = {"Cache-Control" : "max-age=7200, must-revalidate, private",


"Origin": "xyz"

"Pragma" : "max-age=7200, must-revalidate, private",

"Device-Info": addDeviceHeader()};

return options;


xyz is being shown in request with proper value when we debug the app in safari but in iOS 12 it's getting replaced with Origin: file://

I’m sorry but I can only help you with Apple APIs. If you can trace this down through the Cordova stack to the Apple API it’s using, I’d be happy to comment on that. If not, my recommendation is that you seek help via Cordova’s support channel.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"