我正在 Angular/Ionic/Capacitor 中开发一个 iOS 应用程序。该应用在 Android 上运行良好,但由于 CORS,服务器调用在 iOS 上被拒绝。
该应用程序使用 WordPress API,其中包括以下功能;
function add_cors_http_header(){
header("Access-Control-Allow-Origin: *");
}
add_action('init','add_cors_http_header');
我尝试在capacitor.config.json 中设置服务器,但没有成功。
也在 config.xml 中尝试了以下内容
<edit-config file="*-Info.plist" mode="merge" target="NSAppTransportSecurity">
config.xml 已经包含
<access origin="*" />
<allow-navigation href="*" />
还是不行?
答案 0 :(得分:0)
我根据this answer
解决了这个问题通过添加
add_filter('kses_allowed_protocols', function($protocols) {
$protocols[] = 'capacitor';
return $protocols;
});