@@ -151,17 +151,23 @@ def evaluate(flow_name: str | None, output_dir: str | None, cache: bool = True):
151151 options = flow .EvaluateAndDumpOptions (output_dir = output_dir , use_cache = cache )
152152 fl .evaluate_and_dump (options )
153153
154- _default_server_settings = lib .ServerSettings .from_env ()
155-
156154COCOINDEX_HOST = 'https://cocoindex.io'
157155
156+ _default_server_settings = None
157+
158+ def _get_default_server_settings ():
159+ global _default_server_settings
160+ if _default_server_settings is None :
161+ _default_server_settings = lib .ServerSettings .from_env ()
162+ return _default_server_settings
163+
158164@cli .command ()
159165@click .option (
160- "-a" , "--address" , type = str , default = _default_server_settings .address ,
166+ "-a" , "--address" , type = str , default = lambda : _get_default_server_settings () .address ,
161167 help = "The address to bind the server to, in the format of IP:PORT." )
162168@click .option (
163169 "-c" , "--cors-origin" , type = str ,
164- default = _default_server_settings .cors_origins and ',' .join (_default_server_settings .cors_origins ),
170+ default = lambda : _get_default_server_settings () .cors_origins and ',' .join (_get_default_server_settings () .cors_origins ),
165171 help = "The origins of the clients (e.g. CocoInsight UI) to allow CORS from. "
166172 "Multiple origins can be specified as a comma-separated list. "
167173 "e.g. `https://cocoindex.io,http://localhost:3000`" )
@@ -184,9 +190,9 @@ def server(address: str, live_update: bool, quiet: bool, cors_origin: str | None
184190
185191 It will allow tools like CocoInsight to access the server.
186192 """
187- cors_origins : set [str ] = set ()
193+ cors_origins : set [str ] = set ()
188194 if cors_origin is not None :
189- cors_origins .update (s for o in cors_origin .split (',' ) if (s := o .strip ()) != '' )
195+ cors_origins .update (s for o in cors_origin .split (',' ) if (s := o .strip ()) != '' )
190196 if cors_cocoindex :
191197 cors_origins .add (COCOINDEX_HOST )
192198 if cors_local is not None :
0 commit comments