Last active
October 28, 2024 19:32
-
-
Save yashuarc/10080747 to your computer and use it in GitHub Desktop.
Enabling CORS on CakePHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function beforeFilter() { | |
parent::beforeFilter(); | |
$this->response->header('Access-Control-Allow-Origin','*'); | |
$this->response->header('Access-Control-Allow-Methods','*'); | |
$this->response->header('Access-Control-Allow-Headers','X-Requested-With'); | |
$this->response->header('Access-Control-Allow-Headers','Content-Type, x-xsrf-token'); | |
$this->response->header('Access-Control-Max-Age','172800'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From CakePHP docs https://book.cakephp.org/4/en/controllers/request-response.html#setting-cross-origin-request-headers-cors