tp5解决跨域问题 --- 2018-06-07

调用该方法:

protected function setHeader()

{

    header('Access-Control-Allow-Origin: ' . Config::get('allow_origin'));

    header('Content-type:application/json;charset=utf-8');

}

或者可使用:

public function kuayu(){

    header('Access-Control-Allow-Origin: *');

    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");

    header('Access-Control-Allow-Methods: GET, POST, PUT');

}

你可能感兴趣的:(tp5解决跨域问题 --- 2018-06-07)