Warning: The magic method SFML_Singleton::__wakeup() must have public visibility in /home/public/wp-content/plugins/sf-move-login/inc/classes/class-sfml-singleton.php on line 72

Warning: Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/sf-move-login/inc/classes/class-sfml-singleton.php:72) in /home/public/wp-includes/rest-api/class-wp-rest-server.php on line 1642

Warning: Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/sf-move-login/inc/classes/class-sfml-singleton.php:72) in /home/public/wp-includes/rest-api/class-wp-rest-server.php on line 1642

Warning: Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/sf-move-login/inc/classes/class-sfml-singleton.php:72) in /home/public/wp-includes/rest-api/class-wp-rest-server.php on line 1642

Warning: Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/sf-move-login/inc/classes/class-sfml-singleton.php:72) in /home/public/wp-includes/rest-api/class-wp-rest-server.php on line 1642

Warning: Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/sf-move-login/inc/classes/class-sfml-singleton.php:72) in /home/public/wp-includes/rest-api/class-wp-rest-server.php on line 1642

Warning: Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/sf-move-login/inc/classes/class-sfml-singleton.php:72) in /home/public/wp-includes/rest-api/class-wp-rest-server.php on line 1642

Warning: Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/sf-move-login/inc/classes/class-sfml-singleton.php:72) in /home/public/wp-includes/rest-api/class-wp-rest-server.php on line 1642

Warning: Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/sf-move-login/inc/classes/class-sfml-singleton.php:72) in /home/public/wp-includes/rest-api/class-wp-rest-server.php on line 1642
{"id":168,"date":"2017-02-28T12:07:24","date_gmt":"2017-02-28T19:07:24","guid":{"rendered":"http:\/\/www.munderwood.ca\/?p=168"},"modified":"2017-02-28T12:07:24","modified_gmt":"2017-02-28T19:07:24","slug":"responding-to-http-options-requests-in-cakephp","status":"publish","type":"post","link":"https:\/\/www.munderwood.ca\/index.php\/2017\/02\/28\/responding-to-http-options-requests-in-cakephp\/","title":{"rendered":"Responding to HTTP OPTIONS requests in CakePHP"},"content":{"rendered":"

I recently needed to add\u00a0Access-Control-Allow-Origin<\/span>\u00a0headers to resources on an API developed with CakePHP.\u00a0There’s a\u00a0good description of how to accomplish this from ThinkingMedia in 2015<\/a>, but it uses DispatcherFilters, which have since been\u00a0deprecated in favour of Middleware<\/a>.<\/p>\n

The $request<\/span>\u00a0 and $response<\/span>\u00a0objects available to middleware have different interfaces than those retrieved from the event data in the dispatch filter, but the logic is essentially the same:<\/p>\n