Fix: Use correct API base URL for client-side fetches
All checks were successful
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 34s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 1m10s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 1s

The compare screen and school search modal were not working because
they were fetching from '/api' directly instead of using the
NEXT_PUBLIC_API_URL environment variable that points to the backend.

Fixed client-side fetch calls in:
- ComparisonView: Fetch comparison data with correct API URL
- SchoolSearchModal: Search schools with correct API URL

This ensures client-side requests go to the FastAPI backend at
the configured URL (e.g., http://localhost:8000/api) rather than
trying to hit non-existent Next.js API routes.

Fixes comparison screen showing no data when schools are selected.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Tudor
2026-02-02 22:42:21 +00:00
parent 19e5199443
commit f04e383ea3
2 changed files with 4 additions and 2 deletions

View File

@@ -36,7 +36,8 @@ export function SchoolSearchModal({ isOpen, onClose }: SchoolSearchModalProps) {
setIsSearching(true);
try {
const response = await fetch(`/api/schools?search=${encodeURIComponent(term)}&page_size=10`);
const apiBaseUrl = process.env.NEXT_PUBLIC_API_URL || '/api';
const response = await fetch(`${apiBaseUrl}/schools?search=${encodeURIComponent(term)}&page_size=10`);
const data = await response.json();
setResults(data.schools || []);
setHasSearched(true);