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

View File

@@ -436,10 +436,17 @@ export async function checkServiceDomain(request: FastifyRequest<CheckServiceDom
export async function checkService(request: FastifyRequest<CheckService>) { export async function checkService(request: FastifyRequest<CheckService>) {
try { try {
const { id } = request.params; 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 (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); if (exposePort) exposePort = Number(exposePort);
const { destinationDocker: { remoteIpAddress, remoteEngine, engine }, exposePort: configuredPort } = await prisma.service.findUnique({ where: { id }, include: { destinationDocker: true } }) 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) { if (found) {
throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` } throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` }
} }
if (otherFqdns && otherFqdns.length > 0) { if (domainsList.find(d => getDomain(d.value) === getDomain(fqdn))) {
for (const ofqdn of otherFqdns) { throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` }
found = await isDomainConfigured({ id, fqdn: ofqdn, remoteIpAddress });
if (found) {
throw { status: 500, message: `Domain ${getDomain(ofqdn).replace('www.', '')} is already in use!` }
}
}
} }
if (exposePort) await checkExposedPort({ id, configuredPort, exposePort, engine, remoteEngine, remoteIpAddress }) if (exposePort) await checkExposedPort({ id, configuredPort, exposePort, engine, remoteEngine, remoteIpAddress })
if (isDNSCheckEnabled && !isDev && !forceSave) { if (isDNSCheckEnabled && !isDev && !forceSave) {
@@ -484,7 +486,7 @@ export async function saveService(request: FastifyRequest<SaveService>, reply: F
} }
const templates = await getTemplates() const templates = await getTemplates()
const service = await prisma.service.findUnique({ where: { id } }) 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) { for (const setting of serviceSetting) {
let { id: settingId, name, value, changed = false, isNew = false, variableName } = setting let { id: settingId, name, value, changed = false, isNew = false, variableName } = setting
if (changed) { if (changed) {

View File

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