From 36068e19dfadc7d1f5f25b38912563dfc2ee6990 Mon Sep 17 00:00:00 2001 From: Jeremy Traini Date: Sun, 26 Mar 2023 19:33:15 +1100 Subject: [PATCH] Fixing CORS issues within the server --- src/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.py b/src/main.py index d208382..57fe652 100644 --- a/src/main.py +++ b/src/main.py @@ -9,6 +9,7 @@ from src.database import clear_v1 from fastapi import FastAPI, Request, HTTPException, UploadFile, File from fastapi.responses import Response, JSONResponse, HTMLResponse, StreamingResponse +from fastapi.middleware.cors import CORSMiddleware from src.error import AuthenticationError, InputError from io import BytesIO import uvicorn @@ -38,6 +39,16 @@ version="0.0.1", openapi_tags=tags_metadata) +origins = ["*"] + +app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + @app.exception_handler(500) async def validation_exception_handler(request: Request, exc: Exception): return JSONResponse(