mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-14 08:18:08 +00:00
fix: accept underscores in domain hostnames for API URL validation
PHP's FILTER_VALIDATE_URL rejects underscores in the host, so domains like https://myapp_service.example.com were rejected by the API and never got a Let's Encrypt certificate. Add an isValidDomainUrl() helper that validates a copy with underscores replaced by hyphens, and route domain validation in the Applications and Services API controllers through it. Fixes #10597
This commit is contained in:
1 parent
52739141ee
commit
74b1077010
4 files changed
+39
-7
No files matched your search
@@ -4,6 +4,16 @@ use App\Models\Application;
|
||||
use App\Models\ServiceApplication;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
function isValidDomainUrl(string $url): bool
|
||||
{
|
||||
// PHP's FILTER_VALIDATE_URL rejects underscores in the host, but they are
|
||||
// accepted by browsers, Let's Encrypt, and common Docker service naming
|
||||
// (e.g. https://myapp_service.example.com). Validate against a copy with
|
||||
// underscores replaced by hyphens (a valid host character) so such domains
|
||||
// are not wrongly rejected; URLs without underscores are unaffected.
|
||||
return filter_var(str_replace('_', '-', $url), FILTER_VALIDATE_URL) !== false;
|
||||
}
|
||||
|
||||
function checkDomainUsage(ServiceApplication|Application|null $resource = null, ?string $domain = null)
|
||||
{
|
||||
$conflicts = [];
|
||||
|
||||
Reference in new issue
Block a user