How can I add a Http header to all of my pages? The website I'm working was developed using CakePhP and I would like to add the header below to all pages.
Access-Control-Allow-Origin: https://url_of_my_website
Thanks in advance for any help!
You can use this:
In AppController.php
public function beforeRender()
{
$this->response->header('Access-Control-Allow-Origin', 'your url');
}
$this->response = $this->response->withHeader('X-CakePHP', 'yes!');, because the response object is immutable therefore must be replaced.