Skip to content

Add configurable CORS support for frontend integration#40

Closed
ademboukabes wants to merge 1 commit intoMicroClub-USTHB:devfrom
ademboukabes:fix/cors-support-v2
Closed

Add configurable CORS support for frontend integration#40
ademboukabes wants to merge 1 commit intoMicroClub-USTHB:devfrom
ademboukabes:fix/cors-support-v2

Conversation

@ademboukabes
Copy link
Copy Markdown
Contributor

Summary

This PR adds configurable CORS support so browser-based frontends can call the mAIcro API from a different origin.

Changes

  • add CORS_ORIGINS configuration support
  • expose parsed CORS origins through config.py
  • integrate FastAPI CORSMiddleware in main.py
  • allow requests only from configured frontend origins
  • document the new setting in .env.example and README.md
  • add API tests covering:
    • preflight success for an allowed origin
    • rejection for an unconfigured origin

Why

Previously, browser-based frontends such as React, Next.js, or Vite apps running on a different port or domain could not call the backend because the API did not return the required CORS headers.

This change enables frontend integration while keeping cross-origin access explicitly configurable.

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.

2 participants