diff --git a/index.html b/index.html
index 1e13cc6..8dd3789 100644
--- a/index.html
+++ b/index.html
@@ -325,28 +325,50 @@
return window.location.protocol === 'https:' ? 'https:' : 'http:'
}
+ function resolveTenantDomain() {
+ var host = String(window.location.hostname || '').trim()
+ if (!host || host === 'localhost' || host === '127.0.0.1') {
+ return 'k.montzar.ir'
+ }
+ return host
+ }
+
+ function getSuperAdminBases() {
+ return [
+ 'https://adm.montzar.ir',
+ 'https://adm.montech.ir',
+ 'https://adm.montest.ir'
+ ]
+ }
+
function getVersionUrls() {
var protocol = getProtocol()
+ var domain = encodeURIComponent(resolveTenantDomain())
+ var urls = getSuperAdminBases().map(function (base) {
+ return base + '/get_version?domain=' + domain
+ })
- return [
- 'https://nerkh.gold/get_version',
+ return urls.concat([
'https://tablo.talasevin.ir/get_version',
'https://abshode-service.montgit.ir/server/get_version',
protocol + '//212.23.201.173:8381/get_version',
protocol + '//91.212.174.137:4040/server/get_version'
- ]
+ ])
}
function getConfigUrls() {
var protocol = getProtocol()
+ var domain = encodeURIComponent(resolveTenantDomain())
+ var urls = getSuperAdminBases().map(function (base) {
+ return base + '/get_user?domain=' + domain
+ })
- return [
- protocol + '//nerkh.gold/get_user',
+ return urls.concat([
protocol + '//tablo.talasevin.ir/get_user',
protocol + '//abshode-service.montgit.ir/server/get_user',
protocol + '//212.23.201.173:8381/get_user',
protocol + '//91.212.174.137:4040/server/get_user'
- ]
+ ])
}
function sortVersionUrls(urls) {
diff --git a/src/config/apply-config.ts b/src/config/apply-config.ts
index f0044f9..459472f 100644
--- a/src/config/apply-config.ts
+++ b/src/config/apply-config.ts
@@ -76,8 +76,8 @@ function resolveRemoteLogo(path: string) {
const lastSuccess = localStorage.getItem('CONFIG_Success_URL')
const base = lastSuccess
- ? lastSuccess.replace(/\/get_user\/?$/i, '').replace(/\/+$/, '')
- : 'https://nerkh.gold'
+ ? lastSuccess.replace(/[?#].*$/, '').replace(/\/get_user\/?$/i, '').replace(/\/+$/, '')
+ : 'https://adm.montzar.ir'
return `${base}/${path.replace(/^\/+/, '')}`
}
diff --git a/src/config/load-config.ts b/src/config/load-config.ts
index 0b9e82b..340c037 100644
--- a/src/config/load-config.ts
+++ b/src/config/load-config.ts
@@ -5,30 +5,43 @@ import { readCachedAppConfig, writeCachedAppConfig } from '@/config/config-cache
const CONFIG_SUCCESS_URL_KEY = 'CONFIG_Success_URL'
export const CONFIG_RETRY_ROUNDS = 5
+const SUPERADMIN_BASES = [
+ 'https://adm.montzar.ir',
+ 'https://adm.montech.ir',
+ 'https://adm.montest.ir',
+] as const
+
function getProtocol() {
return window.location.protocol === 'https:' ? 'https:' : 'http:'
}
+function resolveTenantDomain() {
+ const host = String(window.location.hostname || '').trim()
+ if (!host || host === 'localhost' || host === '127.0.0.1') {
+ return 'k.montzar.ir'
+ }
+ return host
+}
+
export function getConfigUrls() {
const protocol = getProtocol()
+ const domain = encodeURIComponent(resolveTenantDomain())
return [
- `${protocol}//nerkh.gold/get_user`,
+ ...SUPERADMIN_BASES.map((base) => `${base}/get_user?domain=${domain}`),
`${protocol}//tablo.talasevin.ir/get_user`,
`${protocol}//abshode-service.montgit.ir/server/get_user`,
`${protocol}//212.23.201.173:8381/get_user`,
- `${protocol}//91.212.174.137:4040/server/get_user`
+ `${protocol}//91.212.174.137:4040/server/get_user`,
]
}
export function sortConfigUrls(urls: string[]) {
const lastSuccessUrl = localStorage.getItem(CONFIG_SUCCESS_URL_KEY)
-
- return [...urls].sort((a, b) => {
- if (a === lastSuccessUrl) return -1
- if (b === lastSuccessUrl) return 1
- return 0
- })
+ if (!lastSuccessUrl || !urls.includes(lastSuccessUrl)) {
+ return [...urls]
+ }
+ return [lastSuccessUrl, ...urls.filter((url) => url !== lastSuccessUrl)]
}
function clearStaleConfigSuccessUrl(url: string) {
@@ -45,10 +58,10 @@ async function fetchConfig(url: string, timeout = 3000): Promise {
const response = await fetch(url, {
method: 'GET',
headers: {
- Accept: 'application/json'
+ Accept: 'application/json',
},
cache: 'no-store',
- signal: controller.signal
+ signal: controller.signal,
})
if (!response.ok) {
diff --git a/src/config/load-version.ts b/src/config/load-version.ts
index 5cbd77d..bed66e0 100644
--- a/src/config/load-version.ts
+++ b/src/config/load-version.ts
@@ -20,13 +20,19 @@ function getProtocol() {
function getVersionUrls() {
const protocol = getProtocol()
+ const host = String(window.location.hostname || '').trim()
+ const domain = encodeURIComponent(
+ !host || host === 'localhost' || host === '127.0.0.1' ? 'k.montzar.ir' : host,
+ )
return [
- 'https://nerkh.gold/get_version',
+ `https://adm.montzar.ir/get_version?domain=${domain}`,
+ `https://adm.montech.ir/get_version?domain=${domain}`,
+ `https://adm.montest.ir/get_version?domain=${domain}`,
'https://tablo.talasevin.ir/get_version',
'https://abshode-service.montgit.ir/server/get_version',
`${protocol}//212.23.201.173:8381/get_version`,
- `${protocol}//91.212.174.137:4040/server/get_version`
+ `${protocol}//91.212.174.137:4040/server/get_version`,
]
}