Skip to content

Commit

Permalink
Fixing CORS issues within the server
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremytraini committed Mar 26, 2023
1 parent add3172 commit 36068e1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 36068e1

Please sign in to comment.