File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- from pydantic import field_validator
21from pydantic_settings import BaseSettings
32
43
54class Settings (BaseSettings ):
65 supabase_url : str = ""
76 supabase_key : str = ""
87 resend_api_key : str = ""
9- cors_origins : list [ str ] = [ "http://localhost:3000" ]
8+ cors_origins : str = "http://localhost:3000"
109
1110 model_config = {"env_file" : ".env" , "env_file_encoding" : "utf-8" }
1211
13- @field_validator ("cors_origins" , mode = "before" )
14- @classmethod
15- def parse_cors_origins (cls , v : object ) -> list [str ]:
16- if isinstance (v , str ):
17- return [o .strip () for o in v .split ("," ) if o .strip ()]
18- return v # type: ignore[return-value]
19-
2012
2113settings = Settings ()
Original file line number Diff line number Diff line change 1212
1313app .add_middleware (
1414 CORSMiddleware ,
15- allow_origins = settings .cors_origins ,
15+ allow_origins = [ o . strip () for o in settings .cors_origins . split ( "," ) if o . strip ()] ,
1616 allow_credentials = True ,
1717 allow_methods = ["*" ],
1818 allow_headers = ["*" ],
You can’t perform that action at this time.
0 commit comments