diff --git a/src/pages/GameList.js b/src/pages/GameList.js index 185c3b6..9776912 100644 --- a/src/pages/GameList.js +++ b/src/pages/GameList.js @@ -20,7 +20,8 @@ const GameList = () => { const [upcomingMatches, setUpcomingMatches] = useState([]); // API URL - const API_URL = 'http://localhost:5500/api'; + const API_HOST = process.env.REACT_APP_API_HOST || 'localhost:5500'; + const API_URL = `http://${API_HOST}/api`; // Format time const formatTime = (timeString) => { diff --git a/src/pages/Home.js b/src/pages/Home.js index 703dc8a..4a6d1b0 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -15,7 +15,8 @@ const Home = () => { const [currentMonth, setCurrentMonth] = useState(new Date()); // API URL - const API_URL = 'http://localhost:5500/api'; + const API_HOST = process.env.REACT_APP_API_HOST || 'localhost:5500'; + const API_URL = `http://${API_HOST}/api`; // Fetch teams data useEffect(() => { diff --git a/src/pages/Home2.js b/src/pages/Home2.js index 6c1c728..65f5ae6 100644 --- a/src/pages/Home2.js +++ b/src/pages/Home2.js @@ -19,7 +19,8 @@ const Home2 = () => { const [upcomingMatches, setUpcomingMatches] = useState([]); // API URL - const API_URL = 'http://localhost:5500/api'; + const API_HOST = process.env.REACT_APP_API_HOST || 'localhost:5500'; + const API_URL = `http://${API_HOST}/api`; // Format time const formatTime = (timeString) => { diff --git a/src/pages/TeamResult.js b/src/pages/TeamResult.js index 8cd6925..14e3e91 100644 --- a/src/pages/TeamResult.js +++ b/src/pages/TeamResult.js @@ -15,7 +15,8 @@ const TeamResults = () => { useEffect(() => { const fetchData = async () => { try { - const response = await fetch("http://localhost:5500/api/teams"); + const API_HOST = process.env.REACT_APP_API_HOST || 'localhost:5500'; + const response = await fetch(`http://${API_HOST}/api/teams`); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); diff --git a/src/pages/Today.js b/src/pages/Today.js index 22cdc58..52af106 100644 --- a/src/pages/Today.js +++ b/src/pages/Today.js @@ -9,7 +9,8 @@ const MatkaResultsDashboard = () => { const [currentDate, setCurrentDate] = useState(''); const [expandedTeams, setExpandedTeams] = useState({}); - const API_URL = 'http://localhost:5500/api'; + const API_HOST = process.env.REACT_APP_API_HOST || 'localhost:5500'; + const API_URL = `http://${API_HOST}/api`; const matkaTeamInfo = { "Desawar Matka": { diff --git a/src/pages/TodaysMatch.js b/src/pages/TodaysMatch.js index 87d7e2c..59aae0a 100644 --- a/src/pages/TodaysMatch.js +++ b/src/pages/TodaysMatch.js @@ -11,7 +11,8 @@ const TodaysMatch = () => { const [currentDate, setCurrentDate] = useState(''); // API URL (from environment variable) - const API_URL = "http://localhost:5500/api"; + const API_HOST = process.env.REACT_APP_API_HOST || 'localhost:5500'; + const API_URL = `http://${API_HOST}/api`; // Format time function const formatTime = (timeString) => { diff --git a/src/pages/UserView.js b/src/pages/UserView.js index cadd8cd..5505e3e 100644 --- a/src/pages/UserView.js +++ b/src/pages/UserView.js @@ -10,7 +10,8 @@ const MatkaResultsDashboard = () => { const [expandedTeams, setExpandedTeams] = useState({}); // API URL - const API_URL = 'http://localhost:5500/api'; + const API_HOST = process.env.REACT_APP_API_HOST || 'localhost:5500'; + const API_URL = `http://${API_HOST}/api`; // Matka team descriptions and tips const matkaTeamInfo = { diff --git a/src/services/DataService.js b/src/services/DataService.js index 633d9a1..f880c8d 100644 --- a/src/services/DataService.js +++ b/src/services/DataService.js @@ -2,8 +2,9 @@ import axios from 'axios'; import { io } from 'socket.io-client'; -const API_URL = 'http://localhost:3000/api'; -const socket = io('http://localhost:3000'); +const API_HOST = process.env.REACT_APP_API_HOST || 'localhost:3000'; +const API_URL = `http://${API_HOST}/api`; +const socket = io(`http://${API_HOST}`); export const DataService = { // Get all teams