Skip to content

Commit

Permalink
fix(ApiResponse): set Accept and Content-Type headers to `applica…
Browse files Browse the repository at this point in the history
…tion/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]>
  • Loading branch information
Lapotor authored Dec 6, 2023
1 parent 743fef8 commit 195a9ca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Http/Responses/ApiErrorResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
) {}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Responses/ApiSuccessResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
) {}

/**
Expand Down

0 comments on commit 195a9ca

Please sign in to comment.