Nagesh Muralidhar commited on
Commit
fbb963b
·
1 Parent(s): 1e0c4ef

midterm-submission

Browse files
Files changed (2) hide show
  1. podcraft/src/pages/Home.tsx +10 -2
  2. server/main.py +2 -2
podcraft/src/pages/Home.tsx CHANGED
@@ -1,6 +1,12 @@
1
  import React, { useState, useEffect, useRef } from 'react';
2
  import '../App.css';
3
 
 
 
 
 
 
 
4
  interface Message {
5
  id: number;
6
  text: string;
@@ -27,7 +33,9 @@ interface ChatResponse {
27
  };
28
  }
29
 
30
- const API_URL = 'http://localhost:8000';
 
 
31
 
32
  const Home: React.FC = () => {
33
  const [messages, setMessages] = useState<Message[]>([
@@ -173,7 +181,7 @@ const Home: React.FC = () => {
173
  )}
174
  <p className="description">{message.description || "An AI-generated debate podcast exploring different perspectives"}</p>
175
  <div className="audio-player">
176
- <audio controls src={`${API_URL}${message.audio_file}`} ref={audioRef}>
177
  Your browser does not support the audio element.
178
  </audio>
179
  </div>
 
1
  import React, { useState, useEffect, useRef } from 'react';
2
  import '../App.css';
3
 
4
+ // Add Vite env type definition
5
+ interface ImportMetaEnv {
6
+ PROD: boolean;
7
+ DEV: boolean;
8
+ }
9
+
10
  interface Message {
11
  id: number;
12
  text: string;
 
33
  };
34
  }
35
 
36
+ // Use relative URLs in production, full URLs in development
37
+ const isDevelopment = window.location.hostname === 'localhost';
38
+ const API_URL = isDevelopment ? 'http://localhost:8000' : '';
39
 
40
  const Home: React.FC = () => {
41
  const [messages, setMessages] = useState<Message[]>([
 
181
  )}
182
  <p className="description">{message.description || "An AI-generated debate podcast exploring different perspectives"}</p>
183
  <div className="audio-player">
184
+ <audio controls src={message.audio_file} ref={audioRef}>
185
  Your browser does not support the audio element.
186
  </audio>
187
  </div>
server/main.py CHANGED
@@ -45,10 +45,10 @@ app = FastAPI()
45
  # Configure CORS for frontend development server
46
  app.add_middleware(
47
  CORSMiddleware,
48
- allow_origins=["http://localhost:5173", "http://localhost:3000"],
49
  allow_credentials=True,
50
  allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD"],
51
- allow_headers=["Content-Type", "Authorization", "Accept"],
52
  expose_headers=["Content-Type", "Content-Length"],
53
  max_age=600,
54
  )
 
45
  # Configure CORS for frontend development server
46
  app.add_middleware(
47
  CORSMiddleware,
48
+ allow_origins=["http://localhost:5173", "http://localhost:3000", "https://*.hf.space", "*"],
49
  allow_credentials=True,
50
  allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD"],
51
+ allow_headers=["*"],
52
  expose_headers=["Content-Type", "Content-Length"],
53
  max_age=600,
54
  )