Skip to content

Commit b56db90

Browse files
committed
fix(frontend): replace hardcoded localhost with environment variable
- Created centralized API config in src/config/api.ts - Reads from VITE_API_URL env var with localhost fallback - Updated Dashboard.tsx to import from config - Added frontend/.env.example for documentation - Resolves production deployment issue where frontend tried to call localhost Fixes #5
1 parent 8d392f6 commit b56db90

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

frontend/.env.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Frontend Environment Variables
2+
# Copy this to .env.local for local development overrides
3+
4+
# Backend API URL
5+
# Production: Set in Vercel dashboard (e.g., https://codeintel-backend.railway.app)
6+
# Development: Defaults to http://localhost:8000 (Docker Compose)
7+
VITE_API_URL=http://localhost:8000
8+
9+
# Supabase Configuration
10+
# Get these from your Supabase project settings
11+
VITE_SUPABASE_URL=https://your-project.supabase.co
12+
VITE_SUPABASE_ANON_KEY=your-anon-key-here

frontend/src/components/Dashboard.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import { ImpactAnalyzer } from './ImpactAnalyzer'
1212
import { PerformanceDashboard } from './PerformanceDashboard'
1313
import { UserNav } from './UserNav'
1414
import type { Repository } from '../types'
15-
16-
const API_URL = 'http://localhost:8000'
15+
import { API_URL } from '../config/api'
1716

1817
type RepoTab = 'overview' | 'search' | 'dependencies' | 'insights' | 'impact'
1918

frontend/src/config/api.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* API Configuration
3+
*
4+
* Centralizes API URL configuration for all frontend components.
5+
*
6+
* - Production: Set VITE_API_URL in Vercel dashboard to Railway backend URL
7+
* - Development: Defaults to localhost:8000 (Docker Compose)
8+
* - Local dev without Docker: Can override with .env.local
9+
*/
10+
11+
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000'
12+
13+
export { API_URL }

0 commit comments

Comments
 (0)