Skip to content

Commit

Permalink
check with ->all()
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin Sickert <[email protected]>
  • Loading branch information
Lapotor committed Dec 11, 2023
1 parent 2ae2d63 commit 7f414d6
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions app/Http/Middleware/JsonOnlyMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ class JsonOnlyMiddleware
*/
public function handle(Request $request, Closure $next): Response
{
// Empty body requests are allowed
if ($request->getContent() === '') {
return $next($request);
}

if (!$request->isJson()) {
if (!empty($request->all()) && !$request->isJson()) {
return response()->json([
'message' => 'Only JSON requests are accepted'
], Response::HTTP_BAD_REQUEST);
Expand Down

0 comments on commit 7f414d6

Please sign in to comment.