fix fqdn check

This commit is contained in:
Andras Bacsai
2022-10-28 09:15:03 +02:00
parent cdb25cd0e9
commit aa27aeafa1
5 changed files with 25 additions and 13 deletions

View File

@@ -436,23 +436,17 @@ export async function checkServiceDomain(request: FastifyRequest<CheckServiceDom
export async function checkService(request: FastifyRequest<CheckService>) {
try {
const { id } = request.params;
let { fqdn, exposePort, forceSave, dualCerts } = request.body;
const otherFqdns = await prisma.serviceSetting.findMany({where: { variableName: {startsWith: '$$coolify_fqdn'}}})
let domainsList = []
let { fqdn, exposePort, forceSave, dualCerts, otherFqdn = false } = request.body;
const domainsList = await prisma.serviceSetting.findMany({ where: { variableName: { startsWith: '$$coolify_fqdn' } } })
if (fqdn) fqdn = fqdn.toLowerCase();
if (otherFqdns && otherFqdns.length > 0) {
domainsList = otherFqdns.filter((f) => {
if(f.serviceId !== id) {
return f
}
});
}
if (exposePort) exposePort = Number(exposePort);
const { destinationDocker: { remoteIpAddress, remoteEngine, engine }, exposePort: configuredPort } = await prisma.service.findUnique({ where: { id }, include: { destinationDocker: true } })
const { isDNSCheckEnabled } = await prisma.setting.findFirst({});
let found = await isDomainConfigured({ id, fqdn, remoteIpAddress });
let found = await isDomainConfigured({ id, fqdn, remoteIpAddress, checkOwn: otherFqdn });
if (found) {
throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` }
}

View File

@@ -40,7 +40,7 @@ export interface CheckService extends OnlyId {
forceSave: boolean,
dualCerts: boolean,
exposePort: number,
otherFqdns: Array<string>
otherFqdn: boolean
}
}
export interface SaveService extends OnlyId {