File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,13 @@ class Settings(BaseSettings):
38
38
list [AnyUrl ] | str , BeforeValidator (parse_cors )
39
39
] = []
40
40
41
+ @computed_field # type: ignore[prop-decorator]
42
+ @property
43
+ def all_cors_origins (self ) -> list [str ]:
44
+ return [str (origin ).rstrip ("/" ) for origin in self .BACKEND_CORS_ORIGINS ] + [
45
+ self .FRONTEND_HOST
46
+ ]
47
+
41
48
PROJECT_NAME : str
42
49
SENTRY_DSN : HttpUrl | None = None
43
50
POSTGRES_SERVER : str
Original file line number Diff line number Diff line change @@ -21,12 +21,10 @@ def custom_generate_unique_id(route: APIRoute) -> str:
21
21
)
22
22
23
23
# Set all CORS enabled origins
24
- if settings .BACKEND_CORS_ORIGINS :
24
+ if settings .all_cors_origins :
25
25
app .add_middleware (
26
26
CORSMiddleware ,
27
- allow_origins = [
28
- str (origin ).strip ("/" ) for origin in settings .BACKEND_CORS_ORIGINS
29
- ],
27
+ allow_origins = settings .all_cors_origins ,
30
28
allow_credentials = True ,
31
29
allow_methods = ["*" ],
32
30
allow_headers = ["*" ],
You can’t perform that action at this time.
0 commit comments