From 8f681e4b25cb6fcf09662669c2253aeda8826c71 Mon Sep 17 00:00:00 2001 From: gitgrahamdunn Date: Wed, 18 Feb 2026 18:17:04 -0700 Subject: [PATCH] Debug: show API base URL on login page --- frontend/src/api.ts | 7 +++++++ frontend/src/components/LoginPanel.tsx | 4 +++- frontend/src/styles.css | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/src/api.ts b/frontend/src/api.ts index 85dca0f..1fe5e1c 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -24,6 +24,10 @@ const frontendEnv = (import.meta as ImportMeta & { const configuredApiUrl = frontendEnv?.VITE_API_URL?.trim()?.replace(/\/$/, ""); const API_BASE_URL = configuredApiUrl || window.location.origin; +export function getApiBaseUrl(): string { + return API_BASE_URL; +} + if (!configuredApiUrl) { console.error( "[api] Missing required VITE_API_URL. Falling back to same-origin requests. " + @@ -160,6 +164,9 @@ export async function login( email: string, password: string, ): Promise { + const loginUrl = buildApiUrl("/auth/login"); + console.log("[auth] Login URL:", loginUrl); + return request("/auth/login", { method: "POST", body: JSON.stringify({ email, password }), diff --git a/frontend/src/components/LoginPanel.tsx b/frontend/src/components/LoginPanel.tsx index 7865bf5..8b84cd3 100644 --- a/frontend/src/components/LoginPanel.tsx +++ b/frontend/src/components/LoginPanel.tsx @@ -1,5 +1,5 @@ import { FormEvent, useState } from "react"; -import { login } from "../api"; +import { getApiBaseUrl, login } from "../api"; import Banner from "./ui/Banner"; import Button from "./ui/Button"; import Card from "./ui/Card"; @@ -14,6 +14,7 @@ export default function LoginPanel({ onToken }: LoginPanelProps): JSX.Element { const [password, setPassword] = useState("user123"); const [error, setError] = useState(null); const [isSubmitting, setIsSubmitting] = useState(false); + const apiBaseUrl = getApiBaseUrl(); async function handleSubmit( event: FormEvent, @@ -57,6 +58,7 @@ export default function LoginPanel({ onToken }: LoginPanelProps): JSX.Element { + API: {apiBaseUrl} {error ? : null} diff --git a/frontend/src/styles.css b/frontend/src/styles.css index de0ed08..7c5b43e 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -48,3 +48,10 @@ th, td { text-align: left; border-bottom: 1px solid #d8dee4; padding: 8px; font- .toast { position: fixed; bottom: 16px; right: 16px; background: #1f883d; color: #fff; padding: 10px 14px; border-radius: 8px; } .error-boundary-fallback { margin: 40px auto; max-width: 640px; background: #fff; border: 1px solid #d0d7de; padding: 20px; border-radius: 8px; } + +.login-api-debug { + display: block; + margin-top: 8px; + color: #57606a; + font-size: 12px; +}