Access-Control-Allow-Origin is not showing up in response headers from codeigniter

后端 未结 4 941
太阳男子
太阳男子 2021-01-03 08:24

My Codeigniter file says

$CI->output->set_header(\"Access-Control-Allow-Origin: *\");
$CI->output->set_header(\"Access-Control-Expose-Headers: Ac         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-03 09:05

    What worked for me is:

    $this->output
      ->set_header('Access-Control-Allow-Origin: http://localhost:4567')
      ->set_header('Content-type: application/json')
      ->set_status_header(200)
      ->set_output( json_encode($to_encode) )
      ->_display();
    

提交回复
热议问题