Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix

Andras Bacsaidc2d15fd9c34
diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts
index 4a4de8be7b..8c1658630d 100644
--- a/apps/api/src/lib/common.ts
+++ b/apps/api/src/lib/common.ts
@@ -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);
}
diff --git a/apps/api/src/routes/api/v1/services/handlers.ts b/apps/api/src/routes/api/v1/services/handlers.ts
index b4f43ea555..52f52c7f27 100644
--- a/apps/api/src/routes/api/v1/services/handlers.ts
+++ b/apps/api/src/routes/api/v1/services/handlers.ts
@@ -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) {
diff --git a/apps/ui/src/routes/services/[id]/index.svelte b/apps/ui/src/routes/services/[id]/index.svelte
index 69a066c548..2109f0d664 100644
--- a/apps/ui/src/routes/services/[id]/index.svelte
+++ b/apps/ui/src/routes/services/[id]/index.svelte
@@ -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);