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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
refactor(github): enhance API request handling and validation
Andras Bacsai36dfd1bc6e1c
diff --git a/app/Http/Controllers/Api/GithubController.php b/app/Http/Controllers/Api/GithubController.phpindex b529b80f3c..b297c0cec7 100644--- a/app/Http/Controllers/Api/GithubController.php+++ b/app/Http/Controllers/Api/GithubController.php@@ -124,8 +124,8 @@ class GithubController extends Controller'organization' => 'nullable|string|max:255','api_url' => 'required|string|url','html_url' => 'required|string|url',- 'custom_user' => 'string|max:255',- 'custom_port' => 'integer|min:1|max:65535',+ 'custom_user' => 'nullable|string|max:255',+ 'custom_port' => 'nullable|integer|min:1|max:65535','app_id' => 'required|integer','installation_id' => 'required|integer','client_id' => 'required|string|max:255',@@ -259,10 +259,13 @@ class GithubController extends Controller$maxPages = 100; // Safety limit: max 10,000 repositorieswhile ($page <= $maxPages) {- $response = Http::withToken($token)->get("{$githubApp->api_url}/installation/repositories", [- 'per_page' => 100,- 'page' => $page,- ]);+ $response = Http::GitHub($githubApp->api_url, $token)+ ->timeout(20)+ ->retry(3, 200, throw: false)+ ->get('/installation/repositories', [+ 'per_page' => 100,+ 'page' => $page,+ ]);if ($response->status() !== 200) {return response()->json([@@ -368,7 +371,10 @@ class GithubController extends Controller$token = generateGithubInstallationToken($githubApp);- $response = Http::withToken($token)->get("{$githubApp->api_url}/repos/{$owner}/{$repo}/branches");+ $response = Http::GitHub($githubApp->api_url, $token)+ ->timeout(20)+ ->retry(3, 200, throw: false)+ ->get("/repos/{$owner}/{$repo}/branches");if ($response->status() !== 200) {return response()->json([diff --git a/app/Livewire/Project/New/GithubPrivateRepository.php b/app/Livewire/Project/New/GithubPrivateRepository.phpindex 0f496e6db3..a2071931eb 100644--- a/app/Livewire/Project/New/GithubPrivateRepository.php+++ b/app/Livewire/Project/New/GithubPrivateRepository.php@@ -143,7 +143,13 @@ class GithubPrivateRepository extends Componentprotected function loadBranchByPage(){- $response = Http::withToken($this->token)->get("{$this->github_app->api_url}/repos/{$this->selected_repository_owner}/{$this->selected_repository_repo}/branches?per_page=100&page={$this->page}");+ $response = Http::GitHub($this->github_app->api_url, $this->token)+ ->timeout(20)+ ->retry(3, 200, throw: false)+ ->get("/repos/{$this->selected_repository_owner}/{$this->selected_repository_repo}/branches", [+ 'per_page' => 100,+ 'page' => $this->page,+ ]);$json = $response->json();if ($response->status() !== 200) {return $this->dispatch('error', $json['message']);diff --git a/bootstrap/helpers/github.php b/bootstrap/helpers/github.phpindex 0de2f2fd97..3b5f183fba 100644--- a/bootstrap/helpers/github.php+++ b/bootstrap/helpers/github.php@@ -135,7 +135,13 @@ function getPermissionsPath(GithubApp $source)function loadRepositoryByPage(GithubApp $source, string $token, int $page){- $response = Http::withToken($token)->get("{$source->api_url}/installation/repositories?per_page=100&page={$page}");+ $response = Http::GitHub($source->api_url, $token)+ ->timeout(20)+ ->retry(3, 200, throw: false)+ ->get('/installation/repositories', [+ 'per_page' => 100,+ 'page' => $page,+ ]);$json = $response->json();if ($response->status() !== 200) {return [