Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ npm install
npm run dev
```

For hosted frontend deployments, set `VITE_API_BASE_URL` to the backend API origin, for example `http://localhost:8000/api/v1` locally or your deployed backend URL in production.

### Option 3 — Ollama (free, no API key)

```bash
Expand Down
1 change: 1 addition & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_BASE_URL=http://localhost:8000/api/v1
14 changes: 11 additions & 3 deletions frontend/src/services/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import axios, { InternalAxiosRequestConfig, AxiosResponse } from 'axios'
import { useAuthStore } from '../stores/authStore'

const configuredApiBaseUrl = import.meta.env.VITE_API_BASE_URL?.trim()
const API_BASE_URL = configuredApiBaseUrl ? configuredApiBaseUrl.replace(/\/$/, '') : '/api/v1'

function buildApiUrl(path: string): string {
const normalizedPath = path.startsWith('/') ? path : `/${path}`
return `${API_BASE_URL}${normalizedPath}`
}

const api = axios.create({
baseURL: '/api/v1',
baseURL: API_BASE_URL,
headers: {
'Content-Type': 'application/json',
},
Expand Down Expand Up @@ -341,7 +349,7 @@ export const ragApi = {
signal?: AbortSignal,
): Promise<void> => {
const token = useAuthStore.getState().token
const resp = await fetch('/api/v1/rag/query/stream', {
const resp = await fetch(buildApiUrl('/rag/query/stream'), {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -493,4 +501,4 @@ export const guardHistoryApi = {
},
}

export default api
export default api
1 change: 1 addition & 0 deletions frontend/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
Loading