From f2eb8092e4c01b4291a4dc4ab86cadaafb5be508 Mon Sep 17 00:00:00 2001 From: Masterain Date: Thu, 16 May 2024 22:25:52 -0700 Subject: [PATCH] Update main.py --- main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 40ee26c..21bfc57 100644 --- a/main.py +++ b/main.py @@ -7,11 +7,20 @@ from api_config import * import os import uvicorn +from fastapi.middleware.cors import CORSMiddleware md5_dict_cache = {} app = FastAPI(docs_url=DOCS_URL, redoc_url=None) db = MysqlConn(DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME) +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + @app.get("/", response_class=RedirectResponse, status_code=302) async def root(): @@ -335,4 +344,4 @@ async def get_checksum(this_game_name: str, background_tasks: BackgroundTasks): for game_name in game_name_id_map.keys(): if not os.path.exists("./dict/{}".format(game_name)): os.makedirs("./dict/{}".format(game_name)) - uvicorn.run(app, host="0.0.0.0", port=8000) + uvicorn.run(app, host="0.0.0.0", port=8900, proxy_headers=True, forwarded_allow_ips="*")