diff --git a/src/routes/applications/[id]/index.svelte b/src/routes/applications/[id]/index.svelte
index 02a158fc5..6d8807123 100644
--- a/src/routes/applications/[id]/index.svelte
+++ b/src/routes/applications/[id]/index.svelte
@@ -64,6 +64,8 @@
let autodeploy = application.settings.autodeploy;
let nonWWWDomain = application.fqdn && getDomain(application.fqdn).replace(/^www\./, '');
+ let isNonWWWDomainOK = false;
+ let isWWWDomainOK = false;
let wsgis = [
{
@@ -143,6 +145,17 @@
} catch ({ error }) {
if (error?.startsWith($t('application.dns_not_set_partial_error'))) {
forceSave = true;
+ if (dualCerts) {
+ isNonWWWDomainOK = await isDNSValid(getDomain(nonWWWDomain), false);
+ isWWWDomainOK = await isDNSValid(getDomain(`www.${nonWWWDomain}`), true);
+ } else {
+ const isWWW = getDomain(application.fqdn).includes('www.');
+ if (isWWW) {
+ isWWWDomainOK = await isDNSValid(getDomain(`www.${nonWWWDomain}`), true);
+ } else {
+ isNonWWWDomainOK = await isDNSValid(getDomain(nonWWWDomain), false);
+ }
+ }
}
return errorNotification(error);
} finally {
@@ -160,12 +173,17 @@
application.baseBuildImage = event.detail.value;
await handleSubmit();
}
- async function isDNSValid(domain) {
+
+ async function isDNSValid(domain, isWWW) {
try {
await get(`/applications/${id}/check.json?domain=${domain}`);
- toast.push('Domain is valid in DNS.');
+ toast.push('DNS configuration is valid.');
+ isWWW ? (isWWWDomainOK = true) : (isNonWWWDomainOK = true);
+ return true;
} catch ({ error }) {
- return errorNotification(error);
+ errorNotification(error);
+ isWWW ? (isWWWDomainOK = false) : (isNonWWWDomainOK = false);
+ return false;
}
}
@@ -412,18 +430,36 @@
placeholder="eg: https://coollabs.io"
/>
{#if forceSave}
-
-
- {#if dualCerts}
+
+ {#if isNonWWWDomainOK}
isDNSValid(getDomain(nonWWWDomain), false)}
+ >DNS settings for {nonWWWDomain} is OK, click to recheck.
+ {:else}
+
+ {/if}
+ {#if dualCerts}
+ {#if isWWWDomainOK}
+
+ {:else}
+
+ {/if}
{/if}
{/if}
diff --git a/src/routes/settings/check.json.ts b/src/routes/settings/check.json.ts
index 22c6c53d8..88eaa0293 100644
--- a/src/routes/settings/check.json.ts
+++ b/src/routes/settings/check.json.ts
@@ -44,7 +44,7 @@ export const post: RequestHandler = async (event) => {
})
};
}
- if (isDNSCheckEnabled && !dev && !forceSave) {
+ if (isDNSCheckEnabled && !forceSave) {
return await checkDomainsIsValidInDNS({ event, fqdn, dualCerts });
}
return {
diff --git a/src/routes/settings/index.svelte b/src/routes/settings/index.svelte
index 7d3f7aad3..c601db4ed 100644
--- a/src/routes/settings/index.svelte
+++ b/src/routes/settings/index.svelte
@@ -50,6 +50,8 @@
let forceSave = false;
let fqdn = settings.fqdn;
let nonWWWDomain = fqdn && getDomain(fqdn).replace(/^www\./, '');
+ let isNonWWWDomainOK = false;
+ let isWWWDomainOK = false;
let isFqdnSet = !!settings.fqdn;
let loading = {
save: false,
@@ -71,6 +73,7 @@
}
async function changeSettings(name) {
try {
+ resetView();
if (name === 'isRegistrationEnabled') {
isRegistrationEnabled = !isRegistrationEnabled;
}
@@ -98,6 +101,7 @@
try {
loading.save = true;
nonWWWDomain = fqdn && getDomain(fqdn).replace(/^www\./, '');
+
if (fqdn !== settings.fqdn) {
await post(`/settings/check.json`, { fqdn, forceSave, dualCerts, isDNSCheckEnabled });
await post(`/settings.json`, { fqdn });
@@ -112,6 +116,17 @@
} catch ({ error }) {
if (error?.startsWith($t('application.dns_not_set_partial_error'))) {
forceSave = true;
+ if (dualCerts) {
+ isNonWWWDomainOK = await isDNSValid(getDomain(nonWWWDomain), false);
+ isWWWDomainOK = await isDNSValid(getDomain(`www.${nonWWWDomain}`), true);
+ } else {
+ const isWWW = getDomain(settings.fqdn).includes('www.');
+ if (isWWW) {
+ isWWWDomainOK = await isDNSValid(getDomain(`www.${nonWWWDomain}`), true);
+ } else {
+ isNonWWWDomainOK = await isDNSValid(getDomain(nonWWWDomain), false);
+ }
+ }
}
return errorNotification(error);
} finally {
@@ -126,14 +141,21 @@
return errorNotification(error);
}
}
- async function isDNSValid(domain) {
+ async function isDNSValid(domain, isWWW) {
try {
await get(`/settings/check.json?domain=${domain}`);
- toast.push('Domain is valid in DNS.');
+ toast.push('DNS configuration is valid.');
+ isWWW ? (isWWWDomainOK = true) : (isNonWWWDomainOK = true);
+ return true;
} catch ({ error }) {
- return errorNotification(error);
+ errorNotification(error);
+ isWWW ? (isWWWDomainOK = false) : (isNonWWWDomainOK = false);
+ return false;
}
}
+ function resetView() {
+ forceSave = false;
+ }
@@ -182,6 +204,7 @@
bind:value={fqdn}
readonly={!$session.isAdmin || isFqdnSet}
disabled={!$session.isAdmin || isFqdnSet}
+ on:input={resetView}
name="fqdn"
id="fqdn"
pattern="^https?://([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{'{'}2,{'}'}$"
@@ -189,18 +212,36 @@
/>
{#if forceSave}
-
-
- {#if dualCerts}
+
+ {#if isNonWWWDomainOK}
isDNSValid(getDomain(nonWWWDomain), false)}
+ >DNS settings for {nonWWWDomain} is OK, click to recheck.
+ {:else}
+
+ {/if}
+ {#if dualCerts}
+ {#if isWWWDomainOK}
+
+ {:else}
+
+ {/if}
{/if}
{/if}