Skip to content

Commit dfd66bf

Browse files
committed
Update API configuration in Dashboard component
1 parent 4b0fd49 commit dfd66bf

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/pages/Dashboard.jsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import axios from 'axios';
66
import PortfolioAnalytics from '../components/dashboard/PortfolioAnalytics';
77
import StockDetail from '../components/dashboard/StockDetail';
88

9-
const API_BASE_URL = 'http://localhost:5000/api';
9+
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'https://portfolio-tracker-backend-y7ne.onrender.com/api';
10+
11+
// Create axios instance with base URL
12+
const api = axios.create({
13+
baseURL: API_BASE_URL,
14+
timeout: 10000
15+
});
1016

1117
const containerVariants = {
1218
hidden: { opacity: 0 },
@@ -122,10 +128,13 @@ export default function Dashboard({ theme: propTheme }) {
122128

123129
const fetchStocks = async () => {
124130
try {
125-
const response = await axios.get(`${API_BASE_URL}/stocks`);
131+
console.log('Fetching stocks from:', API_BASE_URL);
132+
const response = await api.get('/stocks');
133+
console.log('Stocks fetched successfully:', response.data);
126134
setStocks(response.data);
127135
setLoading(false);
128136
} catch (err) {
137+
console.error('Error fetching stocks:', err);
129138
setError('Failed to fetch stocks');
130139
setLoading(false);
131140
}

0 commit comments

Comments
 (0)