fastadmin关闭了tp的路由功能,不支持路由设置跨域,简单粗暴在入口文件添加如下代码:
// 允许全局跨域 header('Access-Control-Allow-Origin: *'); header('Access-Control-Max-Age: 1800'); header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, OPTIONS, DELETE'); header('Access-Control-Allow-Headers: *'); if (strtoupper($_SERVER['REQUEST_METHOD']) == "OPTIONS") { http_response_code(204); exit; }