Skip to content

feat(p28b): CORS for Vercel + Cloudflare-Tunnel deploy guide#50

Merged
harsh-pandhe merged 2 commits into
mainfrom
feat/p28b-cors-vercel-deploy
May 24, 2026
Merged

feat(p28b): CORS for Vercel + Cloudflare-Tunnel deploy guide#50
harsh-pandhe merged 2 commits into
mainfrom
feat/p28b-cors-vercel-deploy

Conversation

@harsh-pandhe
Copy link
Copy Markdown
Owner

Operator path for the Vercel SPA → Cloudflare Tunnel → local FastAPI architecture you're planning. Three pieces.

1. CORS that doesn't deadlock the browser

The middleware passed allow_origins=['*'] + allow_credentials=True — browsers refuse the combo. Fixed:

  • wildcard * in origins → allow_credentials=False (Bearer JWT + X-API-Key still work)
  • concrete origins → credentials on (OAuth callback / cookie sessions work)

Also exposes Retry-After + X-Request-ID so the SPA can read them.

2. docs/DEPLOY_VERCEL_TUNNEL.md

Full operator guide: architecture diagram, env-var checklist, systemd unit for ropeway serve, cloudflared named-tunnel + quick-tunnel paths, Vercel-side env (ROPEWAY_API_BASE + ROPEWAY_API_KEY), round-trip smoke tests, troubleshooting matrix.

3. .env.example

Every operator-relevant env in one file, grouped by phase (core / CORS / P28 / OAuth / Razorpay / observability), with secret-generation one-liners.

Test plan

  • tests/test_cors_vercel.py6 tests: wildcard disables credentials, concrete origin allows + echoes, foreign origin rejected, Retry-After in expose-headers, deploy guide keyword check, .env.example key check

…xample

P28b — operator path for the Vercel-frontend + local-compute
architecture. Three pieces:

1. CORS that doesn't deadlock the browser.
   The existing middleware passed allow_origins=['*'] together with
   allow_credentials=True, which browsers refuse. The new code reads
   the cors_origins list and:
     - wildcard ('*' present) -> credentials disabled (still works for
       header-based auth: Bearer JWT, X-API-Key);
     - concrete origins -> credentials kept on, so cookie/session flows
       (OAuth callback) work too.
   Also exposes Retry-After + X-Request-ID via Access-Control-Expose-
   Headers so the Vercel SPA can read them.

2. docs/DEPLOY_VERCEL_TUNNEL.md — full operator guide:
   architecture diagram (Vercel SPA -> Cloudflare Tunnel -> FastAPI
   on your box), env-var checklist, systemd unit for ropeway serve,
   cloudflared install + named-tunnel-vs-quick-tunnel setup, Vercel
   side env (ROPEWAY_API_BASE + ROPEWAY_API_KEY), round-trip smoke
   tests (health, API key, rate limit), backup/update/troubleshooting.

3. .env.example at the repo root — every operator-relevant env var
   in one file, grouped by phase (core / CORS / P28 / OAuth / Razorpay
   / observability), with secret-generation one-liners.

Tests: tests/test_cors_vercel.py — 6 new
  - wildcard origin disables credentials (browser-safe)
  - concrete Vercel origin allows credentials + echoes origin back
  - other origins rejected even when allow-list is set
  - Retry-After listed in Access-Control-Expose-Headers
  - DEPLOY_VERCEL_TUNNEL.md ships the required keywords
  - .env.example carries every operator-critical env var
@harsh-pandhe harsh-pandhe merged commit 18772a4 into main May 24, 2026
2 checks passed
@harsh-pandhe harsh-pandhe deleted the feat/p28b-cors-vercel-deploy branch May 24, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant