Browse Source

feat(module): Add fastapi CORS

huangrunheng 2 years ago
parent
commit
462a50982b
1 changed files with 10 additions and 0 deletions
  1. 10 0
      module/server/app.py

+ 10 - 0
module/server/app.py

@@ -3,6 +3,7 @@
 # github https://github.com/runhey
 import argparse
 from fastapi import FastAPI
+from fastapi.middleware.cors import CORSMiddleware
 
 from module.logger import logger
 
@@ -14,6 +15,15 @@ app = FastAPI(
     description='OAS web service',
     version='0.0.0',
 )
+
+app.add_middleware(
+    CORSMiddleware,
+    allow_origins=["*"],
+    allow_credentials=True,
+    allow_methods=["*"],
+    allow_headers=["*"]
+)
+
 app.include_router(home_app)
 app.include_router(script_app)