diff --git a/server.py b/server.py index 04c8f39..8d7d8d1 100644 --- a/server.py +++ b/server.py @@ -9,12 +9,20 @@ from fastapi.responses import JSONResponse from pathlib import Path from bs4 import BeautifulSoup from rich.logging import RichHandler +from fastapi.middleware.cors import CORSMiddleware logging.basicConfig(level=logging.INFO, format="%(message)s", datefmt="[%X]", handlers=[RichHandler(markup=True)]) app = fastapi.FastAPI( root_path=os.environ.get("PREVIEW_ROOT_PATH", ""), ) +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["GET", "OPTIONS"], + allow_headers=["*", "Authorization"], +) MISSING_TOKEN = JSONResponse( {"errcode": "M_MISSING_TOKEN", "error": "Missing access token"},