From 594017e1dff464a453502dcdc8c0d6e05804f555 Mon Sep 17 00:00:00 2001 From: Salim Khraimeche Date: Fri, 15 Mar 2024 15:20:51 +0100 Subject: [PATCH] fix Option --- public/index.php | 1 + src/Controller/QuestionController.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/public/index.php b/public/index.php index ddffe44..9fd8213 100644 --- a/public/index.php +++ b/public/index.php @@ -18,6 +18,7 @@ spl_autoload_register(function ($class_name) { header("Access-Control-Allow-Origin: *"); //Todo: A mettre dans le .htaccess +header("Access-Control-Allow-Headers: Content-Type"); // Charger les routes à partir du fichier de configuration $routes = require '../src/Router/routes.php'; diff --git a/src/Controller/QuestionController.php b/src/Controller/QuestionController.php index 335a878..29c3ad5 100644 --- a/src/Controller/QuestionController.php +++ b/src/Controller/QuestionController.php @@ -39,6 +39,9 @@ class QuestionController { $data = json_decode(file_get_contents('php://input')); $question = new Question(text:$data->text); + + if($data->text === null) + return; foreach ($data->answers as $answer) { -- GitLab