AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
[TOC] ## 基础跨域方式 ``` header('Access-Control-Allow-Origin: *'); ``` - 2018年5月15日又被坑了   这种方式 进行接收所提交上来的数据 但是还没有解析 ``` header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (strtolower($_SERVER['REQUEST_METHOD']) == 'options') { exit; } $data=file_get_contents("php://input"); //2018年10月10日 tp5.1框架的request可以获取这种参数 ``` ## phpStudy5.6版本无法跨域 - 2018年2月13日17:20:36 被坑了一下午 一般来说 配置 header("Access-Control-Allow-Credentials: true"); 就能解决问题 在用 phpStudy继承环境 php版本为php-5.6.27-nts 时,发现这样的方式解决不了跨域问题,在需要在php.ini 中将 always_populate_raw_post_data = -1 这句打开 ## laravel5.4跨域 https://segmentfault.com/a/1190000008963017 - 2018年3月28日  laravel5.4跨域 1 创建中间件 允许跨域的header ``` <?php namespace App\Http\Middleware; use Closure; use Illuminate\Support\Facades\Auth; class AccessControlAllowOrigin{ public function handle($request, Closure $next) { header('Access-Control-Allow-Origin: *'); header("Access-Control-Allow-Credentials: true"); header("Access-Control-Allow-Methods: *"); header("Access-Control-Allow-Headers: Content-Type,Access-Token"); header("Access-Control-Expose-Headers: *"); return $next($request); } } ``` 2注册中间件 在kernel中添加