Skip to content

FastAdmin跨域配置

修改Api基控制器的_initialize 的方法

PHP
        //跨域请求检测(注释)
        //check_cors_request();
        //配置跨域请求(添加)
        header('Access-Control-Allow-Origin: *');
        header('Access-Control-Allow-Methods: POST, GET, PUT, OPTIONS, DELETE'); //请求方法
        header('Access-Control-Allow-Headers: Origin, X-Requested-With, Control-Type, Content-Type, token, Accept, x-access-sign, x-access-time');
        if (request()->isOptions()) {
            exit();
        }