H
H
hollanditkzn2017-08-24 16:54:50
Yii
hollanditkzn, 2017-08-24 16:54:50

Why doesn't the cors filter work for me?

How to properly write a cors filter for a controller.
Here is my example

public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'],
                ],
            ],
            'corsFilter' => [
                'class' => Cors::className(),
                'cors' => [
                    'Origin' => ['http://localhost:3001/socket.io/1/?t=1503580684584'],
                    'Access-Control-Request-Method' => ['GET'],
                    'Access-Control-Allow-Credentials' => true,
                ]
            ],
];
}

I still get an error

GET localhost:3001/socket.io/1/?t=1503582467989 403 (Forbidden)
XMLHttpRequest cannot load localhost:3001/socket.io/1/?t=1503582467989. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' crm ' is therefore not allowed access. The response had HTTP status code 403.

How to write correctly so that everything works?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
davidnum95, 2017-08-24
@davidnum95

and on port 3001 exactly the web server with yii is spinning?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question