Skip to content

fix(api): add CORS middleware for frontend browser integrationFix backend cors support#431

Open
Arijit429 wants to merge 4 commits intofireform-core:mainfrom
Arijit429:fix-backend-cors-support
Open

fix(api): add CORS middleware for frontend browser integrationFix backend cors support#431
Arijit429 wants to merge 4 commits intofireform-core:mainfrom
Arijit429:fix-backend-cors-support

Conversation

@Arijit429
Copy link
Copy Markdown

@Arijit429 Arijit429 commented Apr 14, 2026

Closes #415

🚀 Summary

This PR adds CORS middleware support to the FastAPI backend to enable seamless browser-based frontend integration.


🐛 Problem

The frontend is served separately (for example from:

http://127.0.0.1:5500

) and communicates with the backend API running on:

http://127.0.0.1:8000

This triggers browser preflight OPTIONS requests.

Without proper CORS configuration, these requests fail with:

400 Bad Request

which blocks all frontend-to-backend communication.


✨ Fix

Added CORSMiddleware in:

api/main.py

Allowed local frontend origins:

http://127.0.0.1:5500
http://localhost:5500

Also enabled:

  • all methods
  • all headers
  • credential support

🎯 Production Impact

This significantly improves deployment readiness by enabling:

  • browser frontend integration
  • local development workflows
  • docker-based frontend/backend separation
  • future cloud deployment compatibility

This is an important production-readiness improvement for the project architecture.

@Arijit429
Copy link
Copy Markdown
Author

Continuing the production-readiness roadmap, this PR focuses on frontend-backend deployment compatibility by enabling proper browser CORS support for separated frontend workflows.

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.

[BUG]: No CORS middleware on FastAPI app — frontend requests blocked by browser

1 participant