File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 11from typing import Any
22from fastapi import FastAPI
33from fastapi .middleware .cors import CORSMiddleware
4+ import re
45
56
67def find_cors_configuration (app : FastAPI , default : Any ) -> Any :
@@ -14,11 +15,14 @@ def find_cors_configuration(app: FastAPI, default: Any) -> Any:
1415 continue
1516
1617 origins = middleware .options .get ("allow_origins" )
17-
18- # Incompatibility fix between CORSMiddleware and python-socketio
19- if origins == ["*" ]:
20- origins = "*"
18+ if origins :
19+ # Incompatibility fix between CORSMiddleware and python-socketio
20+ if origins == ["*" ]:
21+ origins = "*"
22+ return origins
2123
22- return origins
24+ origins_regex = middleware .options .get ("allow_origin_regex" )
25+ if origins_regex :
26+ return lambda value : re .match (origins_regex , value ) is not None
2327
2428 return default
You can’t perform that action at this time.
0 commit comments