Spaces:
Sleeping
Sleeping
File size: 608 Bytes
805a069 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | function normalizeHostname(hostname: string): string {
return hostname.trim().toLowerCase()
}
export function isLocalDashboardHost(hostname: string): boolean {
const normalized = normalizeHostname(hostname)
return (
normalized === 'localhost' ||
normalized === '127.0.0.1' ||
normalized === '::1' ||
normalized.endsWith('.local')
)
}
export function shouldRedirectDashboardToHttps(input: {
protocol: string
hostname: string
forceHttps?: boolean
}): boolean {
if (!input.forceHttps) return false
return input.protocol === 'http:' && !isLocalDashboardHost(input.hostname)
}
|