Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Fix wrong destination issue on create_application

W8jonasbf6b3b8c7127
diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.php
index 1e045ff5a6..ac4aacd101 100644
--- a/app/Http/Controllers/Api/ApplicationsController.php
+++ b/app/Http/Controllers/Api/ApplicationsController.php
@@ -1095,6 +1095,17 @@ class ApplicationsController extends Controller
return response()->json(['message' => 'Server has multiple destinations and you do not set destination_uuid.'], 400);
}
$destination = $destinations->first();
+ if ($destinations->count() > 1 && $request->has('destination_uuid')) {
+ $destination = $destinations->where('uuid', $request->destination_uuid)->first();
+ if (! $destination) {
+ return response()->json([
+ 'message' => 'Validation failed.',
+ 'errors' => [
+ 'destination_uuid' => 'Provided destination_uuid does not belong to the specified server.',
+ ],
+ ], 422);
+ }
+ }
if ($type === 'public') {
$validationRules = [
'git_repository' => ['string', 'required', new ValidGitRepositoryUrl],