This commit is contained in:
Andras Bacsai 2022-10-27 20:05:02 +00:00
parent 55cb788380
commit dc2d15fd9c
3 changed files with 21 additions and 21 deletions

View File

@ -281,9 +281,7 @@ export async function isDomainConfigured({
where: {
OR: [
{ fqdn: { endsWith: `//${nakedDomain}` } },
{ fqdn: { endsWith: `//www.${nakedDomain}` } },
{ minio: { apiFqdn: { endsWith: `//${nakedDomain}` } } },
{ minio: { apiFqdn: { endsWith: `//www.${nakedDomain}` } } }
{ fqdn: { endsWith: `//www.${nakedDomain}` } }
],
id: { not: checkOwn ? undefined : id },
destinationDocker: {
@ -303,6 +301,7 @@ export async function isDomainConfigured({
},
select: { fqdn: true }
});
console.log({foundApp, foundService})
return !!(foundApp || foundService || coolifyFqdn);
}

View File

@ -436,10 +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, otherFqdns, dualCerts } = request.body;
let { fqdn, exposePort, forceSave, dualCerts } = request.body;
const otherFqdns = await prisma.serviceSetting.findMany({where: { variableName: {startsWith: '$$coolify_fqdn'}}})
let domainsList = []
if (fqdn) fqdn = fqdn.toLowerCase();
if (otherFqdns && otherFqdns.length > 0) otherFqdns = otherFqdns.map((f) => f.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 } })
@ -449,13 +456,8 @@ export async function checkService(request: FastifyRequest<CheckService>) {
if (found) {
throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` }
}
if (otherFqdns && otherFqdns.length > 0) {
for (const ofqdn of otherFqdns) {
found = await isDomainConfigured({ id, fqdn: ofqdn, remoteIpAddress });
if (found) {
throw { status: 500, message: `Domain ${getDomain(ofqdn).replace('www.', '')} is already in use!` }
}
}
if (domainsList.find(d => getDomain(d.value) === getDomain(fqdn))) {
throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` }
}
if (exposePort) await checkExposedPort({ id, configuredPort, exposePort, engine, remoteEngine, remoteIpAddress })
if (isDNSCheckEnabled && !isDev && !forceSave) {
@ -484,7 +486,7 @@ export async function saveService(request: FastifyRequest<SaveService>, reply: F
}
const templates = await getTemplates()
const service = await prisma.service.findUnique({ where: { id } })
const foundTemplate = templates.find(t => fixType(t.name) === service.type)
const foundTemplate = templates.find(t => fixType(t.name) === fixType(service.type))
for (const setting of serviceSetting) {
let { id: settingId, name, value, changed = false, isNew = false, variableName } = setting
if (changed) {

View File

@ -78,13 +78,12 @@
if (loading.save) return;
loading.save = true;
try {
// await post(`/services/${id}/check`, {
// fqdn: service.fqdn,
// forceSave,
// dualCerts,
// otherFqdns: service.minio?.apiFqdn ? [service.minio?.apiFqdn] : [],
// exposePort: service.exposePort
// });
await post(`/services/${id}/check`, {
fqdn: service.fqdn,
forceSave,
dualCerts,
exposePort: service.exposePort
});
const formData = new FormData(e.target);
if (formData) service = await saveForm(formData, service);
setLocation(service);