fix: add CORS middleware for cross-origin frontend access #260
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/pal-e-api!260
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "258-fix-add-cors-middleware-to-allow-pal-e-p"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds CORSMiddleware to the FastAPI app so the frontend at
pal-e-production.tail5b443a.ts.netcan make cross-origin fetch() calls to the API without being blocked by browser CORS policy. Origins are configured via thePALDOCS_ALLOWED_ORIGINSenv var (comma-separated).Changes
src/pal_e_docs/config.py— Addedallowed_origins: str = ""to Settings (env var:PALDOCS_ALLOWED_ORIGINS)src/pal_e_docs/main.py— ImportCORSMiddlewarefrom starlette and conditionally add it when origins are configured. Allows GET/POST/PUT/PATCH/DELETE/OPTIONS methods, all headers, no credentials.Test Plan
PALDOCS_ALLOWED_ORIGINS=https://pal-e-production.tail5b443a.ts.netset in the environmentAccess-Control-Allow-OriginheaderPALDOCS_ALLOWED_ORIGINSunset/empty, verify no CORS headers are added (backward compatible)Review Checklist
*default origin — origins must be explicitly configuredRelated Notes
None.
Related
Closes #258
Self-review: LGTM. Minimal, correctly scoped change. No issues found.