From 56335cbfa78dce301990d5cc332ac64b91cc4ea2 Mon Sep 17 00:00:00 2001 From: Utsho Dey Date: Wed, 18 Dec 2024 13:16:48 +0600 Subject: [PATCH] fixed pipeline error --- main.py | 24 +++--------------------- tests/test_main.py | 5 +---- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/main.py b/main.py index 6db5c7d..6d8bb26 100644 --- a/main.py +++ b/main.py @@ -11,46 +11,28 @@ app = FastAPI( ) # CORS configuration -origins = [ - FRONTEND_URL, - "http://localhost", - "http://localhost:5173", - "http://0.0.0.0", - "http://0.0.0.0:5173", - "*" -] - - app.add_middleware( CORSMiddleware, - allow_origins=origins, - allow_credentials=True, + allow_origins=["*"], # Only wildcard + allow_credentials=False, # Changed to False to work with wildcard allow_methods=["*"], allow_headers=["*"], ) - # Basic root endpoint @app.get("/") async def root(): return {"message": "Welcome to your FastAPI application"} - # Health check endpoint @app.get("/health") async def health_check(): return {"status": "healthy"} - app.include_router(fact_check_router, prefix="") app.include_router(aifact_check_router, prefix="") app.include_router(scrap_websites_router, prefix="") -# Include routers (uncomment and modify as needed) -# from routes import some_router -# app.include_router(some_router, prefix="/your-prefix", tags=["your-tag"]) - if __name__ == "__main__": import uvicorn - - uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) + uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) \ No newline at end of file diff --git a/tests/test_main.py b/tests/test_main.py index e71e19a..47a3536 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -3,19 +3,16 @@ from main import app client = TestClient(app) - def test_root_endpoint(): response = client.get("/") assert response.status_code == 200 assert response.json() == {"message": "Welcome to your FastAPI application"} - def test_health_endpoint(): response = client.get("/health") assert response.status_code == 200 assert response.json() == {"status": "healthy"} - def test_cors_headers(): response = client.get("/", headers={"Origin": "http://localhost:5173"}) - assert response.headers["access-control-allow-origin"] == "http://localhost:5173" + assert response.headers["access-control-allow-origin"] == "*" \ No newline at end of file