diff --git a/frontend/src/contexts/AuthContext.tsx b/frontend/src/contexts/AuthContext.tsx index baa7d2c..e253b06 100644 --- a/frontend/src/contexts/AuthContext.tsx +++ b/frontend/src/contexts/AuthContext.tsx @@ -20,6 +20,7 @@ interface AuthContextType { } const AuthContext = createContext(undefined); +const API_BASE_URL = process.env.REACT_APP_API_BASE_URL || 'http://localhost:3002/api'; interface AuthProviderProps { children: ReactNode; @@ -48,7 +49,7 @@ export const AuthProvider: React.FC = ({ children }) => { const checkSetupStatus = async (): Promise => { try { console.log('🔍 Checking setup status...'); - const response = await fetch('http://localhost:3002/api/setup/status'); + const response = await fetch(`${API_BASE_URL}/setup/status`); if (!response.ok) { throw new Error('Setup status check failed'); } @@ -72,7 +73,7 @@ export const AuthProvider: React.FC = ({ children }) => { return; } - const response = await fetch('http://localhost:3002/api/auth/me', { + const response = await fetch(`${API_BASE_URL}/auth/me`, { headers: { 'Authorization': `Bearer ${token}` } @@ -104,7 +105,7 @@ export const AuthProvider: React.FC = ({ children }) => { try { console.log('🔐 Attempting login for:', credentials.email); - const response = await fetch('http://localhost:3002/api/auth/login', { + const response = await fetch(`${API_BASE_URL}/auth/login`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/frontend/src/services/authService.ts b/frontend/src/services/authService.ts index 03ec5fa..3345a15 100644 --- a/frontend/src/services/authService.ts +++ b/frontend/src/services/authService.ts @@ -1,6 +1,6 @@ // frontend/src/services/authService.ts import { Employee } from '../models/Employee'; -const API_BASE = 'http://localhost:3002/api'; +const API_BASE = process.env.REACT_APP_API_BASE_URL || 'http://localhost:3002/api'; export interface LoginRequest { email: string;