Skip to content

Commit 195a9ca

Browse files
authored
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 <[email protected]>
1 parent 743fef8 commit 195a9ca

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

app/Http/Responses/ApiErrorResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct(
1818
private $message,
1919
private ?Throwable $exception = null,
2020
private int $status = Response::HTTP_INTERNAL_SERVER_ERROR,
21-
private array $headers = []
21+
private array $headers = ["Content-Type" => "application/json", "Accept" => "application/json"]
2222
) {}
2323

2424
/**

app/Http/Responses/ApiSuccessResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ApiSuccessResponse implements Responsable
1616
public function __construct(
1717
private $data,
1818
private int $status = Response::HTTP_OK,
19-
private array $headers = []
19+
private array $headers = ["Content-Type" => "application/json", "Accept" => "application/json"]
2020
) {}
2121

2222
/**

0 commit comments

Comments
 (0)