pear2007

pear2007

这家伙有点懒,还没写个性签名!

  • 财富值4995
  • 威望值70
  • 总积分6705

个人信息

  • 2020-04-26 已签到
    连续签到1天,获得了5个金钱
  • 2020-04-22 已签到
    连续签到1天,获得了5个金钱
  • 2020-04-15 已签到
    连续签到1天,获得了5个金钱
  • 2020-04-01 已签到
    连续签到2天,获得了10个金钱
  • 2020-03-31 已签到
    连续签到1天,获得了5个金钱
  • 2020-03-04 已签到
    连续签到1天,获得了5个金钱
  • 回复了 的评论

    按照上面做的,一直报401,Your request was made with invalid credentials

    可以参考下

    public function behaviors(){
        $behaviors = parent::behaviors();
        $auth = $behaviors['authenticator'];
        unset($behaviors['authenticator']);
        // add CORS filter
        $behaviors['corsFilter'] = [
            'class' => \yii\filters\Cors::class,
            'cors' => [
                // restrict access to
                'Origin' => ['*'],
                'Access-Control-Request-Method' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'],
                'Access-Control-Request-Headers' => ['*'],
    //                'Access-Control-Allow-Credentials' => true,
                // Allow OPTIONS caching
                'Access-Control-Max-Age' => 3600,
                // Allow the X-Pagination-Current-Page header to be exposed to the browser.
                'Access-Control-Expose-Headers' => ['x-pagination-current-page','x-pagination-page-count','x-pagination-per-page','x-pagination-total-count','link'],
            ],
        ];
    
        // re-add authentication filter
        $behaviors['authenticator'] = $auth;
        // avoid authentication on CORS-pre-flight requests (HTTP OPTIONS method)
        $behaviors['authenticator']['except'] = ['options'];
    
        if (Yii::$app->getRequest()->getMethod() !== 'OPTIONS') {
            $behaviors['authenticator'] = [
                'class' =>  HttpBearerAuth::class,
            ];
        }
    
    
        return $behaviors;
    }
    
  • 2020-01-20 已签到
    连续签到1天,获得了5个金钱
  • 2020-01-17 已签到
    连续签到2天,获得了10个金钱
  • 2020-01-16 已签到
    连续签到1天,获得了5个金钱
副总裁 等级规则
6705/10000
资料完整度
20/100
用户活跃度
0/100

Ta的关注

11

Ta的粉丝

13

Ta的访客

52