Skip to content

Commit ecabd89

Browse files
committed
Fix API response parsing and remove /api prefix from backend routes
- Fixed chat-session-sidebar.tsx to check for 'success' field instead of 'status' - Removed /api prefix from backend router to match frontend expectations - Backend endpoints now directly accessible at /chat, /contracts, etc - Frontend properly parses session list responses
1 parent 84fdea2 commit ecabd89

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

backend/api/app_new.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def init_chatbot():
101101
allow_headers=["*"],
102102
)
103103

104-
# Include API router
105-
app.include_router(router, prefix="/api")
104+
# Include API router (no prefix - backend is a standalone service)
105+
app.include_router(router)
106106

107107

108108
# Global exception handlers for better error responses

frontend/app/chat/chat-session-sidebar.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { DropdownMenuContent } from '@/components/ui/dropdown-menu';
1919
import { DropdownMenu } from '@/components/ui/dropdown-menu';
2020
import { DropdownMenuTrigger } from '@radix-ui/react-dropdown-menu';
2121

22+
const apiBase = (process.env.NEXT_PUBLIC_API_URL || '').replace(/\/$/, '');
23+
2224
interface Session {
2325
id?: string;
2426
session_id?: string;
@@ -29,7 +31,7 @@ interface Session {
2931
}
3032

3133
interface ChatSessionSidebarProps {
32-
variant?: 'inset' | 'overlay';
34+
variant?: 'inset' | 'sidebar' | 'floating';
3335
onSessionSelect: (sessionId: string) => void;
3436
}
3537

@@ -52,9 +54,9 @@ export function ChatSessionSidebar({ variant, onSessionSelect }: ChatSessionSide
5254
React.useEffect(() => {
5355
const fetchSessions = async () => {
5456
try {
55-
const response = await fetch('/api/sessions');
57+
const response = await fetch(`${apiBase}/chat/sessions`);
5658
const data = await response.json();
57-
if (data.status === 'success' && Array.isArray(data.sessions)) {
59+
if (data.success && Array.isArray(data.sessions)) {
5860
setSessions(data.sessions);
5961
} else {
6062
setSessions([]); // Ensure sessions is an array even if API response is unexpected

0 commit comments

Comments
 (0)