Skip to content

Commit 45c3ae7

Browse files
validate backend URL and auth_enabled values in config endpoint; remove unused error card import in HomeInput component
1 parent 42b728c commit 45c3ae7

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/frontend/frontend_server.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from fastapi.middleware.cors import CORSMiddleware
88
from fastapi.responses import FileResponse, HTMLResponse
99
from fastapi.staticfiles import StaticFiles
10+
from urllib.parse import urlparse
1011

1112
# Load environment variables from .env file
1213
load_dotenv()
@@ -40,14 +41,21 @@ async def get_config():
4041
backend_url = os.getenv("BACKEND_API_URL", "http://localhost:8000")
4142
auth_enabled = os.getenv("AUTH_ENABLED", "false")
4243

43-
# Validate backend_url is a proper URL
44-
if not backend_url.startswith(("http://", "https://")):
44+
# Validate backend_url is a proper URL with scheme and netloc
45+
try:
46+
parsed = urlparse(backend_url)
47+
if not (parsed.scheme in ["http", "https"] and parsed.netloc):
48+
backend_url = "http://localhost:8000"
49+
except Exception:
4550
backend_url = "http://localhost:8000"
4651

4752
backend_url = backend_url + "/api"
4853

4954
# Validate auth_enabled is a boolean string
50-
auth_enabled = auth_enabled.lower() if auth_enabled.lower() in ["true", "false"] else "false"
55+
if auth_enabled and auth_enabled.lower() in ["true", "false"]:
56+
auth_enabled = auth_enabled.lower()
57+
else:
58+
auth_enabled = "false"
5159

5260
config = {
5361
"API_URL": backend_url,

src/frontend/src/components/content/HomeInput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import "./../../styles/HomeInput.css";
1717
import { HomeInputProps, iconMap, QuickTask } from "../../models/homeInput";
1818
import { TaskService } from "../../services/TaskService";
1919
import { NewTaskService } from "../../services/NewTaskService";
20-
import { RAIErrorCard, RAIErrorData } from "../errors";
2120

2221
import ChatInput from "@/coral/modules/ChatInput";
2322
import InlineToaster, { useInlineToaster } from "../toast/InlineToaster";

0 commit comments

Comments
 (0)