php跨域处理
php跨域處理
$allow_origin = array('http://xxxx', ); $origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';if (in_array($origin, $allow_origin)) {header('Access-Control-Allow-Origin:' . $origin); }else{header('Access-Control-Allow-Origin: *'); } header('Access-Control-Allow-Headers:Content-Type'); header('Access-Control-Allow-Credentials:true'); //是否支持cookie跨域 header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE"); header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization, Cookie, TEST-USER-ID, TEST-TOKEN,test-token,adt-user-id");總結
- 上一篇: 郝斌_数据结构入门笔记
- 下一篇: 工具调研类型模板