[英]CORS header 'Access-Control-Allow-Origin' missing - PHP, Angular
Currently developing an API in PHP which has the following headers 当前正在用PHP开发具有以下标头的API
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
header('Access-Control-Allow-Headers: Content-Type');
which works when called from Postman and from an Ionic application. 从Postman和Ionic应用程序调用时可以正常工作。
However when calling it from a web application on localhost using angular I get an error with 但是,当使用angular从本地主机上的Web应用程序调用它时,出现错误
Reason: CORS header 'Access-Control-Allow-Origin' missing).
原因:CORS标头“ Access-Control-Allow-Origin”丢失)。
Despite the header being present and other application applications being able to call it. 尽管标题存在并且其他应用程序应用程序也可以调用它。
Add the following to your config.xml file: 将以下内容添加到您的config.xml文件中:
<access origin="*"/>
<allow-intent href="*"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.