Skip to content

Commit 1087a96

Browse files
authored
Merge pull request #32 from CUAHSI/rm-allow-origins
use allow_origins_regex for CORS
2 parents 2f31f67 + 12270c3 commit 1087a96

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

api/com_res/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323
swagger_ui_parameters=swagger_params,
2424
)
2525

26-
origins = [get_settings().allow_origins]
26+
origins_from_settings = get_settings().allow_origins
27+
28+
if origins_from_settings is None:
29+
origins_from_settings = ".*"
2730

2831
app.add_middleware(
2932
CORSMiddleware,
30-
allow_origins=origins,
33+
allow_origin_regex=origins_from_settings,
3134
allow_credentials=True,
3235
allow_methods=["*"],
3336
allow_headers=["*"],

env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ VITE_APP_API_HOST=localhost
3636
VITE_APP_API_URL=https://localhost/api
3737

3838
# ALLOW_ORIGINS=${VITE_APP_ORIGIN}
39-
ALLOW_ORIGINS=http://localhost:5173
39+
ALLOW_ORIGINS=.*localhost.*'
4040

4141
# OAUTH2_REDIRECT_URL=${VITE_APP_API_URL}/auth/cuahsi/callback
4242
OAUTH2_REDIRECT_URL=https://localhost/api/auth/cuahsi/callback

0 commit comments

Comments
 (0)