Skip to content

Commit 7f655d4

Browse files
committed
fix: add Vercel origin https://skill-graph-rho.vercel.app to CORS settings and document in DEPLOYMENT_TROUBLESHOOTING.md
1 parent 8246a5e commit 7f655d4

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

DEPLOYMENT_TROUBLESHOOTING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,27 @@ git commit -m "fix: optimize learning recommendations with single query and 2s t
123123
git push
124124
```
125125
Render will build and deploy the updated service automatically.
126+
127+
---
128+
129+
## 📌 Incident 4: API Requests Blocked by CORS Policy on Vercel Deployment
130+
131+
### 🔍 Symptoms
132+
* API calls (like `/recs/gap-analysis`) fail immediately with `net::ERR_FAILED` or `Failed to fetch`.
133+
* The browser console displays the following error:
134+
`Access to fetch at 'https://skillgraph-backend-14k8.onrender.com/api/v1/recs/gap-analysis' from origin 'https://skill-graph-rho.vercel.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.`
135+
136+
### 🧩 Root Cause
137+
The frontend application is hosted on Vercel at `https://skill-graph-rho.vercel.app`. However, this URL was not included in the default `BACKEND_CORS_ORIGINS` list inside the backend configuration file (`app/core/config.py`). Because of this, the FastAPI CORSMiddleware rejected the request preflights and did not return the required `Access-Control-Allow-Origin` headers, causing the browser to block the frontend's API requests.
138+
139+
### 🚀 Solution
140+
Added the production Vercel frontend URL `"https://skill-graph-rho.vercel.app"` to the `BACKEND_CORS_ORIGINS` list in `backend/app/core/config.py`.
141+
142+
### 📋 How to Deploy the Fix
143+
Commit and push the updates:
144+
```bash
145+
git add backend/app/core/config.py
146+
git commit -m "fix: allow Vercel origin https://skill-graph-rho.vercel.app in CORS backend settings"
147+
git push
148+
```
149+
Render will deploy the updated config, and the Vercel app will be able to connect to the backend without CORS issues.

backend/app/core/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class Settings(BaseSettings):
2222
"http://localhost:3000",
2323
"http://localhost:8000",
2424
"http://127.0.0.1:3000",
25-
"http://127.0.0.1:8000"
25+
"http://127.0.0.1:8000",
26+
"https://skill-graph-rho.vercel.app"
2627
]
2728

2829
@field_validator("BACKEND_CORS_ORIGINS", mode="before")

0 commit comments

Comments
 (0)