以下的函数作为每个请求的前置操作 (thinkphp框架)
public function appInit(&$params)
{
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: token,Origin, X-Requested-With, Content-Type, Accept");
header('Access-Control-Allow-Methods: POST,GET');
if(request()->isOptions()){
exit();
}
}

相关文章:

  • 2019-08-25
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-12-04
  • 2021-11-14
  • 2018-05-01
相关资源
相似解决方案