ozee31 / cakephp-cors

A CakePHP (3.3+) plugin for activate cors domain in your application
MIT License
43 stars 31 forks source link

Problem on the ErrorController when BaseErrorController is not on App namespace. #1

Closed alysson-azevedo closed 7 years ago

alysson-azevedo commented 7 years ago

Since I don't use App as my namespace, this line raises an error.

alysson-azevedo commented 7 years ago

i'm not sure if it works, but how about using Cake\Core\App::classname('Error', 'Controller', 'Controller') to return the correct ErrorController classname?

ozee31 commented 7 years ago

OK, I see the problem. I will try to do differently to get around the problem.

AlanCrevon commented 7 years ago

Same problem here :)

AlanCrevon commented 7 years ago

Looks like using

use Cake\Controller\ErrorController as BaseErrorController;

solves the problem here. @alysson-azevedo : you might want to test.

Edit : naaaa... This is not a universal solution. Forget about it. Sorry.

ozee31 commented 7 years ago

Ok, with the new release you can change the ErrorController class.

In app.php you can write

'Cors' => [
    'ErrorController' => 'Other\Namespace\ErrorController',
]

but in this controller you must add

public function beforeRender(Event $event) {
    // ...
    $this->response->header(['Access-Control-Allow-Origin' => '*']);
}

It's OK for you ?

alysson-azevedo commented 7 years ago

seems good for me.