From 2ce6e2670f63714481b33adb6f23bf6ed92ab779 Mon Sep 17 00:00:00 2001 From: StackUnderflow10 Date: Wed, 7 Jan 2026 22:01:45 +0530 Subject: [PATCH 1/2] fixed the cors issue and connect frontend to fastAPI --- app/app.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/app.py b/app/app.py index d029d2c..dd44b81 100644 --- a/app/app.py +++ b/app/app.py @@ -1,6 +1,8 @@ # app/app.py from fastapi import FastAPI, Security, File, UploadFile +#newly added for the cors problem +from fastapi.middleware.cors import CORSMiddleware from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials from .schema import ( LoginSchema, @@ -32,6 +34,19 @@ from .user import get_user_menu app = FastAPI() +# app/app.py + +app.add_middleware( + CORSMiddleware, + # Allow both localhost and the 127.0.0.1 loopback + allow_origins=[ + "http://localhost:3000", + "http://127.0.0.1:3000", + ], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) security = HTTPBearer() @app.post('/auth/verify-staff', tags=["verify"]) From fd9b98ba5ceaebb29fadaf5226ceb02bd69b85e4 Mon Sep 17 00:00:00 2001 From: StackUnderflow10 Date: Thu, 8 Jan 2026 12:21:35 +0530 Subject: [PATCH 2/2] my fixes in app.py --- app/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.py b/app/app.py index dd44b81..dffee98 100644 --- a/app/app.py +++ b/app/app.py @@ -38,7 +38,7 @@ app.add_middleware( CORSMiddleware, - # Allow both localhost and the 127.0.0.1 loopback + allow_origins=[ "http://localhost:3000", "http://127.0.0.1:3000",