diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.php index 4576c37d6..e6de5d532 100644 --- a/app/Http/Controllers/Api/ApplicationsController.php +++ b/app/Http/Controllers/Api/ApplicationsController.php @@ -1094,7 +1094,14 @@ class ApplicationsController extends Controller if ($destinations->count() > 1 && ! $request->has('destination_uuid')) { return response()->json(['message' => 'Server has multiple destinations and you do not set destination_uuid.'], 400); } - $destination = $destinations->first(); + if ($request->has('destination_uuid')) { + $destination = $destinations->where('uuid', $request->destination_uuid)->first(); + if (! $destination) { + return response()->json(['message' => 'Destination not found.'], 404); + } + } else { + $destination = $destinations->first(); + } if ($type === 'public') { $validationRules = [ 'git_repository' => ['string', 'required', new ValidGitRepositoryUrl],