saadrizvi09 commited on
Commit
68c1d18
Β·
1 Parent(s): 8626b2e

fixed graph

Browse files
Dockerfile.fullstack CHANGED
@@ -77,18 +77,27 @@ sleep 2
77
  redis-cli ping > /dev/null
78
  echo "βœ… Redis is ready"
79
 
80
- # Start Backend in background
81
- echo "πŸ”§ Starting NestJS backend..."
 
82
  cd /app/backend
83
- PORT=3001 node dist/main.js &
84
  BACKEND_PID=$!
85
  sleep 3
86
- echo "βœ… Backend started (PID: $BACKEND_PID)"
 
 
 
 
 
 
 
87
 
88
  # Start Frontend (foreground - keeps container alive)
89
- echo "🌐 Starting Next.js frontend on port 7860..."
 
90
  cd /app/frontend
91
- PORT=7860 node server.js
92
 
93
  EOF
94
 
 
77
  redis-cli ping > /dev/null
78
  echo "βœ… Redis is ready"
79
 
80
+ # Start Backend in background on port 3001
81
+ # Use BACKEND_PORT to avoid conflict with the frontend PORT env var
82
+ echo "πŸ”§ Starting NestJS backend on port 3001..."
83
  cd /app/backend
84
+ BACKEND_PORT=3001 node dist/main.js &
85
  BACKEND_PID=$!
86
  sleep 3
87
+
88
+ # Verify backend is running
89
+ if kill -0 $BACKEND_PID 2>/dev/null; then
90
+ echo "βœ… Backend started (PID: $BACKEND_PID)"
91
+ else
92
+ echo "❌ Backend failed to start!"
93
+ exit 1
94
+ fi
95
 
96
  # Start Frontend (foreground - keeps container alive)
97
+ # PORT=7860 is already set via Docker ENV
98
+ echo "🌐 Starting Next.js frontend on port ${PORT}..."
99
  cd /app/frontend
100
+ HOSTNAME=0.0.0.0 node server.js
101
 
102
  EOF
103
 
backend/src/main.ts CHANGED
@@ -18,7 +18,8 @@ async function bootstrap() {
18
 
19
  app.setGlobalPrefix('api');
20
 
21
- const port = process.env.PORT || 3001;
 
22
  await app.listen(port);
23
  console.log(`WagerKit API running on http://localhost:${port}`);
24
  }
 
18
 
19
  app.setGlobalPrefix('api');
20
 
21
+ // Use BACKEND_PORT to avoid conflicts with frontend PORT on Hugging Face
22
+ const port = process.env.BACKEND_PORT || 3001;
23
  await app.listen(port);
24
  console.log(`WagerKit API running on http://localhost:${port}`);
25
  }
frontend/src/app/market/[slug]/page.tsx CHANGED
@@ -94,6 +94,9 @@ export default function MarketDetailPage() {
94
  const [loading, setLoading] = useState(true);
95
 
96
  useEffect(() => {
 
 
 
97
  if (slug) {
98
  getMarketDetail(slug)
99
  .then(setMarket)
@@ -463,7 +466,7 @@ export default function MarketDetailPage() {
463
  </div>
464
 
465
  <div className="h-80">
466
- <Line data={chartData} options={chartOptions} />
467
  </div>
468
  </div>
469
 
 
94
  const [loading, setLoading] = useState(true);
95
 
96
  useEffect(() => {
97
+ // Reset state when slug changes to prevent showing stale market data
98
+ setMarket(null);
99
+ setLoading(true);
100
  if (slug) {
101
  getMarketDetail(slug)
102
  .then(setMarket)
 
466
  </div>
467
 
468
  <div className="h-80">
469
+ <Line key={slug} data={chartData} options={chartOptions} />
470
  </div>
471
  </div>
472
 
frontend/src/lib/api.ts CHANGED
@@ -8,12 +8,14 @@ function getToken(): string | null {
8
  async function apiFetch(path: string, options: RequestInit = {}) {
9
  const headers: Record<string, string> = {
10
  'Content-Type': 'application/json',
 
11
  ...(options.headers as Record<string, string>),
12
  };
13
 
14
  const res = await fetch(`${API_URL}${path}`, {
15
  ...options,
16
  headers,
 
17
  });
18
 
19
  if (!res.ok) {
 
8
  async function apiFetch(path: string, options: RequestInit = {}) {
9
  const headers: Record<string, string> = {
10
  'Content-Type': 'application/json',
11
+ 'Cache-Control': 'no-cache',
12
  ...(options.headers as Record<string, string>),
13
  };
14
 
15
  const res = await fetch(`${API_URL}${path}`, {
16
  ...options,
17
  headers,
18
+ cache: 'no-store',
19
  });
20
 
21
  if (!res.ok) {