fix: dynamically resolve localhost/127.0.0.1 in links to active hostname for remote access

This commit is contained in:
Hitonabi
2026-06-25 23:06:25 +02:00
parent 8d5885d683
commit e9fb72fdc7
8 changed files with 75 additions and 66 deletions
+9
View File
@@ -4,3 +4,12 @@ import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export function resolveExternalUrl(url?: string): string {
if (!url) return ""
const currentHostname = window.location.hostname
if (currentHostname !== "127.0.0.1" && currentHostname !== "localhost" && currentHostname !== "") {
return url.replace(/127\.0\.0\.1|localhost/g, currentHostname)
}
return url
}