diff options
| -rw-r--r-- | includes/functions.php | 1 | ||||
| -rw-r--r-- | public/bookmarks/add/index.php | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/includes/functions.php b/includes/functions.php index 0118807..7146795 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -8,6 +8,7 @@ function respondAndExit(int $responseCode, string $header, array $headers = []): header($header); } + header("Access-Control-Allow-Origin: *"); header('Content-Type: text/plain; charset=UTF-8'); exit(); diff --git a/public/bookmarks/add/index.php b/public/bookmarks/add/index.php index 7df8ced..835fa64 100644 --- a/public/bookmarks/add/index.php +++ b/public/bookmarks/add/index.php @@ -2,10 +2,18 @@ error_reporting(E_ALL); + require_once(__DIR__.'/../../../includes/functions.php'); $config = require_once(__DIR__.'/../../../config.php'); +if ('OPTIONS' === filter_input(INPUT_SERVER, 'REQUEST_METHOD')) { + respondAndExit(200, 'OK', [ + 'Access-Control-Allow-Methods: POST', + 'Access-Control-Allow-Headers: Content-Type, Authorization', + ]); +} + if ('POST' !== filter_input(INPUT_SERVER, 'REQUEST_METHOD')) { respondAndExit(405, 'Method Not Allowed'); } |
