Skip to content

Commit afa7755

Browse files
committed
fix: scope CORS regex to project name, not all Vercel apps
https://.*\.vercel\.app is too broad -- allows any Vercel project to call our backend. Scoped to https://opencodeintel.*\.vercel\.app so only our preview deploys are allowed.
1 parent 8b97d27 commit afa7755

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ GITHUB_REDIRECT_URI=http://localhost:3000/auth/github/callback
4141
# Comma-separated list of allowed origins
4242
ALLOWED_ORIGINS=http://localhost:3000
4343
# Regex for dynamic CORS origins (Vercel preview deploys)
44-
# Set on Railway to allow PR preview URLs to call the backend
45-
# ALLOW_ORIGIN_REGEX=https://.*\.vercel\.app
44+
# Scoped to our project name so only our previews can call the backend
45+
# ALLOW_ORIGIN_REGEX=https://opencodeintel.*\.vercel\.app
4646

4747
# Redis (auto-configured in Docker, set REDIS_URL in Railway)
4848
REDIS_HOST=redis

backend/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ async def dispatch(self, request: Request, call_next):
7575
app.add_middleware(RequestSizeLimitMiddleware)
7676

7777
ALLOWED_ORIGINS = os.getenv("ALLOWED_ORIGINS", "http://localhost:3000").split(",")
78-
# Allow Vercel preview deploys (dynamic subdomains) so PRs can be tested
79-
# against the production backend without CORS issues
78+
# Allow Vercel preview deploys so PRs can be tested against prod backend.
79+
# Set to project-scoped regex: https://opencodeintel.*\.vercel\.app
8080
ALLOW_ORIGIN_REGEX = os.getenv("ALLOW_ORIGIN_REGEX", "")
8181
app.add_middleware(
8282
CORSMiddleware,

0 commit comments

Comments
 (0)