A
A
Albert Tobacco2015-04-20 18:53:23
Yii
Albert Tobacco, 2015-04-20 18:53:23

How to allow cross domain requests in Yii 2?

public function behaviors()
    {
        return [
            'corsFilter' => [
                'class' => \yii\filters\Cors::className(),
                'cors' => [
                    // restrict access to
                    'Origin' => ['*'],

                ],

            ],
        ];
    }

I wrote this in the controller, but nothing happens. I get Bad Request (#400). Unable to verify your data submission.
I need to send statistics from other sites to my ajax. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Makarov, 2015-04-21
@bighoc

Like this: https://github.com/samdark/yii2-cookbook/blob/mast...

V
Vit, 2015-04-20
@fornit1917

CSRF validation disabled?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question