diff --git a/.gitignore b/.gitignore index 7c3d27f..a3427bf 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ dist dist-ssr *.local .env +.env.* .env.local # Editor directories and files diff --git a/backend/__pycache__/main.cpython-312.pyc b/backend/__pycache__/main.cpython-312.pyc index ff90522..bbd86dd 100644 Binary files a/backend/__pycache__/main.cpython-312.pyc and b/backend/__pycache__/main.cpython-312.pyc differ diff --git a/backend/main.py b/backend/main.py index 24cdb1d..438c0ce 100644 --- a/backend/main.py +++ b/backend/main.py @@ -24,10 +24,17 @@ app = FastAPI( ) # CORS middleware (MUST be before routes) +cors_origins = [settings.frontend_url] +if settings.environment == "development": + cors_origins.extend([ + "http://localhost:8000", + "http://127.0.0.1:8000", + "http://localhost:5173", + ]) + app.add_middleware( CORSMiddleware, - allow_origins=["http://localhost:8000", - "http://127.0.0.1:8000", "http://localhost:5173"], + allow_origins=cors_origins, allow_credentials=True, allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"], allow_headers=["*"], diff --git a/backend/requirements.txt b/backend/requirements.txt index 332067e..efd5ae2 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -5,4 +5,3 @@ pydantic==2.5.0 python-dotenv==1.0.0 pydantic-settings==2.1.0 python-multipart==0.0.6 -cors==1.0.1 diff --git a/src/lib/api.ts b/src/lib/api.ts index 16b096a..66f6694 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -3,7 +3,7 @@ * Handles all communication with the backend API */ -const API_BASE_URL = 'http://localhost:8001' +const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:8001' type ApiOptions = { method?: 'GET' | 'POST' | 'PUT' | 'DELETE' diff --git a/src/pages/HistoryPage.tsx b/src/pages/HistoryPage.tsx index c9c4a55..e676ac2 100644 --- a/src/pages/HistoryPage.tsx +++ b/src/pages/HistoryPage.tsx @@ -180,12 +180,12 @@ export default function HistoryPage() {
Your past reflections
- */}