From 195a9cac89a7c0a2771f5ce806cf8ab53d0f09a1 Mon Sep 17 00:00:00 2001 From: Lapotor <17144397+Lapotor@users.noreply.github.com> Date: Wed, 6 Dec 2023 04:49:59 +0100 Subject: [PATCH] fix(ApiResponse): set `Accept` and `Content-Type` headers to `application/json` (#50) Fixes that the API responses were missing the necessary headers. This ensures that the `Accept` and `Content-Type` headers are correctly set to `application/json` for improved compatibility and adherence to best practices in API development. Signed-off-by: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> --- app/Http/Responses/ApiErrorResponse.php | 2 +- app/Http/Responses/ApiSuccessResponse.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Responses/ApiErrorResponse.php b/app/Http/Responses/ApiErrorResponse.php index 4ad3845f..f78754c7 100644 --- a/app/Http/Responses/ApiErrorResponse.php +++ b/app/Http/Responses/ApiErrorResponse.php @@ -18,7 +18,7 @@ public function __construct( private $message, private ?Throwable $exception = null, private int $status = Response::HTTP_INTERNAL_SERVER_ERROR, - private array $headers = [] + private array $headers = ["Content-Type" => "application/json", "Accept" => "application/json"] ) {} /** diff --git a/app/Http/Responses/ApiSuccessResponse.php b/app/Http/Responses/ApiSuccessResponse.php index b8deb1ed..c2daec82 100644 --- a/app/Http/Responses/ApiSuccessResponse.php +++ b/app/Http/Responses/ApiSuccessResponse.php @@ -16,7 +16,7 @@ class ApiSuccessResponse implements Responsable public function __construct( private $data, private int $status = Response::HTTP_OK, - private array $headers = [] + private array $headers = ["Content-Type" => "application/json", "Accept" => "application/json"] ) {} /**