mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-15 20:25:23 +02:00
Merge pull request #2943 from Dokploy/2905-subdomain-length-of-random-traefik-domain-isnt-checked-and-exceeds-maximum
feat(domain): truncate project name to comply with domain label lengt…
This commit is contained in:
@@ -37,7 +37,16 @@ export const generateRandomDomain = ({
|
||||
const hash = randomBytes(3).toString("hex");
|
||||
const slugIp = serverIp.replaceAll(".", "-").replaceAll(":", "-");
|
||||
|
||||
return `${projectName}-${hash}${slugIp === "" ? "" : `-${slugIp}`}.traefik.me`;
|
||||
// Domain labels have a max length of 63 characters
|
||||
// Reserve space for: hash (6) + separators (1-2) + ip section + dot + traefik.me (10)
|
||||
// Approx: 6 + 2 + (variable ip length) + 11 = ~19-30 chars for other parts
|
||||
const maxProjectNameLength = 40;
|
||||
const truncatedProjectName =
|
||||
projectName.length > maxProjectNameLength
|
||||
? projectName.substring(0, maxProjectNameLength)
|
||||
: projectName;
|
||||
|
||||
return `${truncatedProjectName}-${hash}${slugIp === "" ? "" : `-${slugIp}`}.traefik.me`;
|
||||
};
|
||||
|
||||
export const generateHash = (length = 8): string => {
|
||||
|
||||
Reference in New Issue
Block a user