作者 wangzhi

跨域请求

1 <?php 1 <?php
2 - 2 +header("Access-Control-Allow-Origin: * ");
  3 +header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
  4 +if($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
  5 + header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
  6 + exit;
  7 +}
3 // +---------------------------------------------------------------------- 8 // +----------------------------------------------------------------------
4 // | ThinkPHP [ WE CAN DO IT JUST THINK ] 9 // | ThinkPHP [ WE CAN DO IT JUST THINK ]
5 // +---------------------------------------------------------------------- 10 // +----------------------------------------------------------------------