我正在运行cakephp应用程序。 以前在以前的服务器上运行正常。 但是将应用程序移至新服务器后,应用程序将两次返回每个响应标头。
请查看带有响应标题的图片。
现在我不确定是什么原因? 我没有在应用程序源代码中进行任何更改。 cakephp控制器具有与CORS相关的以下代码
public function beforeFilter() {
parent::beforeFilter();
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT");
header("Access-Control-Allow-Headers: x-requested-with, Content-Type, origin, authorization, accept, client-security-token");
//////
header('Cache-Control: no-store, private, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0, max-stale = 0', false); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Expires: 0', false);
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Pragma: no-cache');
//////
$this->Auth->allow(array('api_testemail','api_settings','api_restaurantslistdp', 'api_userdetails', 'api_login','api_editprofile',
'api_saveimage','api_removeitemsall','api_clearmemcache','api_getmemcachekeys','api_getmemcachestats',
'api_getresmenu','api_displaycart','api_getsingleproduct','api_cart','api_removeitems',
'api_increaseqty','api_decreaseqty','api_getsingleaddress','api_deleteaddress','api_promocode',
'api_checkrestaurant','api_nearestofferbyadd','api_restaurantslistbyaddb','api_checkprinterstatus','api_versioncheck','api_getprinterstatusfromiconnectbulk'));
}
我已经尝试通过从此处删除php header()行来查看它是否创建重复条目。 但没有运气。 一直以来,我都在响应头中加倍加倍,导致在Android应用程序中出现以下错误:
Access to XMLHttpRequest at 'http://example.com/backend/api/mobile/login' from origin 'http://localhost:8100' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.
谁能帮帮我吗?