Skip to content

Commit f2eb809

Browse files
committed
Update main.py
1 parent 1305c43 commit f2eb809

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

main.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@
77
from api_config import *
88
import os
99
import uvicorn
10+
from fastapi.middleware.cors import CORSMiddleware
1011

1112
md5_dict_cache = {}
1213
app = FastAPI(docs_url=DOCS_URL, redoc_url=None)
1314
db = MysqlConn(DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME)
1415

16+
app.add_middleware(
17+
CORSMiddleware,
18+
allow_origins=["*"],
19+
allow_credentials=True,
20+
allow_methods=["*"],
21+
allow_headers=["*"],
22+
)
23+
1524

1625
@app.get("/", response_class=RedirectResponse, status_code=302)
1726
async def root():
@@ -335,4 +344,4 @@ async def get_checksum(this_game_name: str, background_tasks: BackgroundTasks):
335344
for game_name in game_name_id_map.keys():
336345
if not os.path.exists("./dict/{}".format(game_name)):
337346
os.makedirs("./dict/{}".format(game_name))
338-
uvicorn.run(app, host="0.0.0.0", port=8000)
347+
uvicorn.run(app, host="0.0.0.0", port=8900, proxy_headers=True, forwarded_allow_ips="*")

0 commit comments

Comments
 (0)