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):
3838 list [AnyUrl ] | str , BeforeValidator (parse_cors )
3939 ] = []
4040
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+
4148 PROJECT_NAME : str
4249 SENTRY_DSN : HttpUrl | None = None
4350 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:
2121)
2222
2323# Set all CORS enabled origins
24- if settings .BACKEND_CORS_ORIGINS :
24+ if settings .all_cors_origins :
2525 app .add_middleware (
2626 CORSMiddleware ,
27- allow_origins = [
28- str (origin ).strip ("/" ) for origin in settings .BACKEND_CORS_ORIGINS
29- ],
27+ allow_origins = settings .all_cors_origins ,
3028 allow_credentials = True ,
3129 allow_methods = ["*" ],
3230 allow_headers = ["*" ],
You can’t perform that action at this time.
0 commit comments