Skip to content

Commit 3756938

Browse files
committed
feat(api): update frontend components to use versioned API_URL
- Remove hardcoded /api/ from all fetch calls - API_URL now includes /api/v1 prefix from config - Updated 8 files: - components/PerformanceDashboard.tsx - components/ImpactAnalyzer.tsx - components/SearchPanel.tsx - components/dashboard/CommandPalette.tsx - components/dashboard/DashboardHome.tsx - hooks/useCachedQuery.ts - pages/LandingPage.tsx - pages/Playground.tsx Before: ${API_URL}/api/repos After: ${API_URL}/repos Part of #55
1 parent 6c8ddaa commit 3756938

8 files changed

Lines changed: 14 additions & 14 deletions

File tree

frontend/src/components/ImpactAnalyzer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function ImpactAnalyzer({ repoId, apiUrl, apiKey }: ImpactAnalyzerProps)
3232
setError('')
3333

3434
try {
35-
const response = await fetch(`${apiUrl}/api/repos/${repoId}/impact`, {
35+
const response = await fetch(`${apiUrl}/repos/${repoId}/impact`, {
3636
method: 'POST',
3737
headers: {
3838
'Authorization': `Bearer ${apiKey}`,

frontend/src/components/PerformanceDashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function PerformanceDashboard({ apiUrl, apiKey }: PerformanceProps) {
1717

1818
const loadMetrics = async () => {
1919
try {
20-
const response = await fetch(`${apiUrl}/api/metrics`, {
20+
const response = await fetch(`${apiUrl}/metrics`, {
2121
headers: { 'Authorization': `Bearer ${apiKey}` }
2222
})
2323
const result = await response.json()

frontend/src/components/SearchPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function SearchPanel({ repoId, apiUrl, apiKey }: SearchPanelProps) {
2525
const startTime = Date.now()
2626

2727
try {
28-
const response = await fetch(`${apiUrl}/api/search`, {
28+
const response = await fetch(`${apiUrl}/search`, {
2929
method: 'POST',
3030
headers: {
3131
'Authorization': `Bearer ${apiKey}`,

frontend/src/components/dashboard/CommandPalette.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export function CommandPalette({ isOpen, onClose }: CommandPaletteProps) {
8383

8484
const fetchRepos = async () => {
8585
try {
86-
const response = await fetch(`${API_URL}/api/repos`, {
86+
const response = await fetch(`${API_URL}/repos`, {
8787
headers: { 'Authorization': `Bearer ${session?.access_token}` }
8888
})
8989
const data = await response.json()

frontend/src/components/dashboard/DashboardHome.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function DashboardHome() {
2727
if (!session?.access_token) return
2828

2929
try {
30-
const response = await fetch(`${API_URL}/api/repos`, {
30+
const response = await fetch(`${API_URL}/repos`, {
3131
headers: { 'Authorization': `Bearer ${session.access_token}` }
3232
})
3333
const data = await response.json()
@@ -50,7 +50,7 @@ export function DashboardHome() {
5050
setLoading(true)
5151
const name = gitUrl.split('/').pop()?.replace('.git', '') || 'unknown'
5252

53-
const response = await fetch(`${API_URL}/api/repos`, {
53+
const response = await fetch(`${API_URL}/repos`, {
5454
method: 'POST',
5555
headers: {
5656
'Authorization': `Bearer ${session?.access_token}`,
@@ -61,7 +61,7 @@ export function DashboardHome() {
6161

6262
const data = await response.json()
6363

64-
await fetch(`${API_URL}/api/repos/${data.repo_id}/index`, {
64+
await fetch(`${API_URL}/repos/${data.repo_id}/index`, {
6565
method: 'POST',
6666
headers: { 'Authorization': `Bearer ${session?.access_token}` }
6767
})
@@ -85,7 +85,7 @@ export function DashboardHome() {
8585

8686
try {
8787
setLoading(true)
88-
await fetch(`${API_URL}/api/repos/${selectedRepo}/index`, {
88+
await fetch(`${API_URL}/repos/${selectedRepo}/index`, {
8989
method: 'POST',
9090
headers: { 'Authorization': `Bearer ${session?.access_token}` }
9191
})

frontend/src/hooks/useCachedQuery.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function useDependencyGraph({ repoId, apiKey, enabled = true }: UseCached
4949
queryKey: ['dependencies', repoId],
5050
queryFn: async () => {
5151
const data = await fetchWithAuth(
52-
`${API_URL}/api/repos/${repoId}/dependencies`,
52+
`${API_URL}/repos/${repoId}/dependencies`,
5353
apiKey
5454
)
5555
// Save to localStorage on successful fetch
@@ -77,7 +77,7 @@ export function useStyleAnalysis({ repoId, apiKey, enabled = true }: UseCachedQu
7777
queryKey: ['style-analysis', repoId],
7878
queryFn: async () => {
7979
const data = await fetchWithAuth(
80-
`${API_URL}/api/repos/${repoId}/style-analysis`,
80+
`${API_URL}/repos/${repoId}/style-analysis`,
8181
apiKey
8282
)
8383
saveToCache('style-analysis', repoId, data)
@@ -109,7 +109,7 @@ export function useImpactAnalysis({
109109
queryKey: ['impact', repoId, filePath],
110110
queryFn: async () => {
111111
const data = await fetchWithAuth(
112-
`${API_URL}/api/repos/${repoId}/impact?file_path=${encodeURIComponent(filePath)}`,
112+
`${API_URL}/repos/${repoId}/impact?file_path=${encodeURIComponent(filePath)}`,
113113
apiKey
114114
)
115115
saveToCache(cacheKey, repoId, data)

frontend/src/pages/LandingPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export function LandingPage() {
114114
const remaining = FREE_LIMIT - searchCount
115115

116116
useEffect(() => {
117-
fetch(`${API_URL}/api/playground/repos`)
117+
fetch(`${API_URL}/playground/repos`)
118118
.then(res => res.json())
119119
.then(data => {
120120
const available = data.repos?.filter((r: any) => r.available).map((r: any) => r.id) || []
@@ -132,7 +132,7 @@ export function LandingPage() {
132132
const startTime = Date.now()
133133

134134
try {
135-
const response = await fetch(`${API_URL}/api/playground/search`, {
135+
const response = await fetch(`${API_URL}/playground/search`, {
136136
method: 'POST',
137137
headers: { 'Content-Type': 'application/json' },
138138
body: JSON.stringify({ query: q, demo_repo: selectedRepo, max_results: 10 })

frontend/src/pages/Playground.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function Playground({ onSignupClick }: PlaygroundProps) {
4848
const startTime = Date.now()
4949

5050
try {
51-
const response = await fetch(`${API_URL}/api/playground/search`, {
51+
const response = await fetch(`${API_URL}/playground/search`, {
5252
method: 'POST',
5353
headers: { 'Content-Type': 'application/json' },
5454
body: JSON.stringify({

0 commit comments

Comments
 (0)