import { getServerSettings } from "./server-settings";
import basePath from "@cocalc/backend/base-path";
export default async function siteURL(dns?: string): Promise<string> {
if (!dns) {
dns = (await getServerSettings()).dns?.toLowerCase();
}
if (!dns) {
dns = "localhost";
}
if (!dns.startsWith("http")) {
dns = "https://" + dns;
}
return `${dns}${basePath == "/" ? "" : basePath}`;
}