remove usage of constants.DASHBOARD_SUBDOMAIN

This commit is contained in:
Girish Ramakrishnan
2024-04-27 11:10:24 +02:00
parent 5420630453
commit 2a6368af60
4 changed files with 18 additions and 16 deletions

View File

@@ -469,24 +469,26 @@ async function writeDashboardNginxConfig(vhost, certificatePath) {
}
// also syncs the certs to disk
async function writeDashboardConfig(domain) {
async function writeDashboardConfig(subdomain, domain) {
assert.strictEqual(typeof subdomain, 'string');
assert.strictEqual(typeof domain, 'string');
debug(`writeDashboardConfig: writing dashboard config for ${domain}`);
const dashboardFqdn = dns.fqdn(constants.DASHBOARD_SUBDOMAIN, domain);
const dashboardFqdn = dns.fqdn(subdomain, domain);
const location = { domain, fqdn: dashboardFqdn, certificate: null };
const certificatePath = await writeCertificate(location);
await writeDashboardNginxConfig(dashboardFqdn, certificatePath);
await reload();
}
async function removeDashboardConfig(domain) {
async function removeDashboardConfig(subdomain, domain) {
assert.strictEqual(typeof subdomain, 'string');
assert.strictEqual(typeof domain, 'string');
debug(`removeDashboardConfig: removing dashboard config of ${domain}`);
const vhost = dns.fqdn(constants.DASHBOARD_SUBDOMAIN, domain);
const vhost = dns.fqdn(subdomain, domain);
const nginxConfigFilename = path.join(paths.NGINX_APPCONFIG_DIR, `dashboard/${vhost}.conf`);
if (!safe.fs.unlinkSync(nginxConfigFilename)) throw new BoxError(BoxError.FS_ERROR, safe.error.message);
@@ -686,8 +688,7 @@ async function checkCerts(options, auditSource, progressCallback) {
for (const app of allApps) {
await writeAppConfigs(app);
}
const { domain:dashboardDomain } = await dashboard.getLocation();
await writeDashboardConfig(dashboardDomain);
await writeDashboardConfig(dashboardLocation.subdomain, dashboardLocation.domain);
await notifyCertChange(); // this allows user to "rebuild" using UI just in case we crashed and went out of sync
safe.fs.unlinkSync(paths.REVERSE_PROXY_REBUILD_FILE);
} else {