diff --git a/lib/_config.php b/lib/_config.php index 5d63b1d..d839edd 100644 --- a/lib/_config.php +++ b/lib/_config.php @@ -4,7 +4,7 @@ define('PRESTO', 'presto.php'); define('PRESTO_VERSION', 'presto-v1.11'); -define('PRESTO_DEBUG', 0); +define('PRESTO_DEBUG', 1); define('PRESTO_TRACE', 1); define('PRESTO_TRACE_KEY', '_presto_trace'); define('VERSION_HEADER', 'X-Api-Version'); @@ -51,6 +51,10 @@ public static function errorHandlerCallback($code, $string, $file, $line, $conte // Set up PHP error handling (note these settings are overriden by explicit PHP ini settigns, we should address this) assert_options(ASSERT_WARNING, 0); +if (PRESTO_DEBUG) { + assert_options(ASSERT_ACTIVE, 1); + assert_options(ASSERT_WARNING, 1); +} ini_set('html_errors', false); error_reporting(E_ALL); set_error_handler(array("PrestoException", "errorHandlerCallback"), E_ALL); diff --git a/lib/api.php b/lib/api.php index 19023e0..b160f96 100644 --- a/lib/api.php +++ b/lib/api.php @@ -53,9 +53,9 @@ public function restrictTo($types) { */ public function crossOrigin() { - + if (empty($_SERVER['HTTP_ORIGIN'])) - throw new Exception("'HTTP_ORIGIN' unknown. Failed to set required 'Access-Control-Allow-Origin' header for CORS handshake.", 500); + return; // This is not a CORS request $this->add_header('Access-Control-Allow-Origin', $_SERVER['HTTP_ORIGIN']); $this->add_header('Access-Control-Allow-Credentials', 'true');