🔥 Question
👉 [Error] Origin null is not allowed by Access-Control-Allow-Origin. Status code: 0
um.. Do you use html canvas in WKWebView?
🧙 Solution
👉 You need to modify the CDVWebView Engine yourself.
If the canvas is contaminated, you can solve it this way.
And add the following two lines after it :)
[configuration.preferences setValue:@TRUE forKey:@"allowFileAccessFromFileURLs"];
[configuration setValue:@"TRUE" forKey:@"allowUniversalAccessFromFileURLs"];
like this!
- (WKWebViewConfiguration*) createConfigurationFromSettings:(NSDictionary*)settings
{
WKWebViewConfiguration* configuration;
if (_configuration) {
configuration = _configuration;
} else {
configuration = [[WKWebViewConfiguration alloc] init];
configuration.processPool = [[CDVWebViewProcessPoolFactory sharedFactory] sharedProcessPool];
[configuration.preferences setValue:@TRUE forKey:@"allowFileAccessFromFileURLs"];
[configuration setValue:@"TRUE" forKey:@"allowUniversalAccessFromFileURLs"];
}
...
🧭 References
[1] reference : https://stackoverflow.com/questions/36000757/cordova-ios-error-origin-null-is-not-allowed-by-access-control-allow-origin
If I was of any help to you, please buy me coffee 😿😢😥
If you have any questions, please leave them in the comments