From eb4d2a9611db8aa59605fe8c5aeb6712b168b890 Mon Sep 17 00:00:00 2001 From: Dominik Milacher Date: Sat, 14 Jun 2025 12:35:48 +0200 Subject: [PATCH] Fix cors issues for now --- email-proxy/proxy.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/email-proxy/proxy.py b/email-proxy/proxy.py index bf0d704..dd755ff 100644 --- a/email-proxy/proxy.py +++ b/email-proxy/proxy.py @@ -19,8 +19,19 @@ engine = create_engine(DATABASE_URL, echo=False) def create_db_and_tables(): SQLModel.metadata.create_all(engine) +from fastapi.middleware.cors import CORSMiddleware + app = FastAPI() +# TODO have some domain list lying around somewhere on the server and pass it to containers +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], # Or specify your frontend domain(s) + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + @app.on_event("startup") def on_startup(): create_db_and_tables() @@ -73,4 +84,4 @@ async def send_brevo_email(to_email, from_name, reply_to_email, subject, message timeout=10, ) if r.status_code >= 400: - raise HTTPException(status_code=500, detail=f"Email failed: {r.text}") + raise HTTPException(status_code=500, detail=f"Email failed: {r.text}") \ No newline at end of file