原生php

在接口前加入

header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Methods:GET,POST");
header('Access-Control-Allow-Headers:x-requested-with,content-type');
header("Content-Type: text/html; charset=utf-8");

thinkphp6

在全局中间件middleware.php文件内加入

\think\middleware\AllowCrossDomain::class
最后修改:2022 年 06 月 03 日
如果觉得我的文章对你有用,请随意赞赏