CORS errors when I have a redirect in the request

Hey guys.
I have the problem with CORS, I’m try to send a Id in the URL and for that I define a pattern in my config

'urlManager' => [
            'enablePrettyUrl' => true,
            'enableStrictParsing' => false,
            'showScriptName' => false,
            'rules' => [
                    'class' => UrlRule::class, 'controller' => [
                    'pluralize' => false,
                    'pattern' => '/controller1/specialword/<my_id:\d+>',
                    'route' => 'controller1/index',
                    'normalizer' => false

in the principal Controller I have the following:

class ActiveController extends \yii\rest\ActiveController
    public function behaviors()
        $behaviors = parent::behaviors();
        // remove auth filter before cors if you are using it
        $behaviors['corsFilter'] = [
            'class' => \yii\filters\Cors::class,
            'cors' => [
                'Origin' => [Yii::$app->request->getOrigin()],
                'Access-Control-Allow-Credentials' => true,
                'Access-Control-Request-Method' => ['GET', 'POST', 'PUT'],
                'Access-Control-Request-Headers' => ['*'],                
        // re-add authentication filter if you are using it.
        $behaviors['authenticator'] = [
            'class' => HttpBearerAuth::class,
        $behaviors['authenticator']['except'] = ['login'];        

        return $behaviors;

In POSTMAN working fine but with my front I have the following error:

Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

I don’t know if the problem is clear, but it is if you do a redirect using a pattern the CORS validation are missing and this is a error.

I don’t found any solution of that, i’m using a altternative solution at the moment.
I don’t lose hope of finding a solution
Thanks :smiley:

Yii::$app->request->getOrigin() 看一下这里面返回的什么内容