From 4974e7d6f360604496d6c23b20394de89e22135b Mon Sep 17 00:00:00 2001 From: Hymmel Date: Thu, 9 Oct 2025 09:42:00 +0200 Subject: [PATCH] sjdkadbksjdkadbk --- frontend/app/page.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index 97192ef..ca1c34a 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -7,7 +7,21 @@ const defaultApiBase = ? 'https://backend.basetracker.lona-development.org' : 'http://localhost:4100'; -const API_BASE = process.env.NEXT_PUBLIC_BACKEND_URL ?? defaultApiBase; +// Normalize backend URL so production always uses HTTPS while keeping local HTTP. +function normalizeApiBase(url: string) { + try { + const parsed = new URL(url); + const isLocalhost = ['localhost', '127.0.0.1', '0.0.0.0'].includes(parsed.hostname); + if (!isLocalhost && parsed.protocol === 'http:') { + parsed.protocol = 'https:'; + } + return parsed.toString().replace(/\/$/, ''); + } catch (_error) { + return url.replace(/\/$/, ''); + } +} + +const API_BASE = normalizeApiBase(process.env.NEXT_PUBLIC_BACKEND_URL ?? defaultApiBase); const API = { signup: `${API_BASE}/auth/signup`,