Skip to content

Commit d0d4a9f

Browse files
add CORS for frontend deploy
1 parent 13febb3 commit d0d4a9f

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
![Python](https://img.shields.io/badge/python-3.11-blue)
44
![FastAPI](https://img.shields.io/badge/fastapi-0.110-green)
5-
5+
![React](https://img.shields.io/badge/react-18.3-blue)
66

77
A web application for exploring Formula 1 driver data, sessions, lap times, and results — using OpenF1 data.
88

9+
Application is live on [https://f1racepace.vercel.app](https://f1racepace.vercel.app)
10+
911
-----
1012

1113
## 🚀 Features
@@ -132,8 +134,9 @@ Now, you can access the application at http://localhost:3000
132134
- [x] Add session stats feature
133135
- [x] Convert to PostgreSQL
134136
- [x] Add lap time comparison feature
135-
- [ ] Deploy to a cloud service (frontend deployed in [Vercel](https://f1racepace.vercel.app))
137+
- [x] Deploy to a cloud service (frontend deployed in Vercel, backend on Hetzner)
136138

139+
Future goal is to add a live data module so users can view and compare driver data from live races.
137140
-----
138141

139142
## 👨‍💻 Author

backend/main.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@
77
from backend.api import sessions, events, drivers, laps
88
from backend.db.database import create_db_and_tables
99

10-
BASE_DIR = Path(__file__).resolve().parent.parent # project root
11-
app = FastAPI(title="F1 Stats",
12-
description="Simple app for F1 statistics")
10+
BASE_DIR = Path(__file__).resolve().parent.parent
11+
app = FastAPI(title="RacePace Backend",
12+
description="API For viewing F1 driver lap times, session results and more.")
1313
app.include_router(events.router)
1414
app.include_router(sessions.router)
1515
app.include_router(drivers.router)
1616
app.include_router(laps.router)
1717

18+
origins = [
19+
"https://f1racepace.vercel.app",
20+
"http://localhost:3000",
21+
]
22+
1823
app.add_middleware(
1924
CORSMiddleware,
20-
allow_origins=["http://localhost:3000"], # frontend dev server
25+
allow_origins=origins,
2126
allow_credentials=True,
2227
allow_methods=["*"],
2328
allow_headers=["*"],
@@ -29,7 +34,7 @@ def on_startup():
2934

3035
@app.get("/")
3136
async def root():
32-
return {"message": "Welcome to F1 Stats API!"}
37+
return {"message": "Connection successful"}
3338

3439
@app.get("/favicon.ico")
3540
def favicon():

0 commit comments

Comments
 (0)