File tree 3 files changed +17
-8
lines changed
3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -62,13 +62,12 @@ async def restart_pool():
62
62
lifespan = _process_pool_lifespan_manager ,
63
63
)
64
64
65
- app .add_middleware (
66
- CORSMiddleware ,
67
- allow_origins = ["*" ],
68
- allow_credentials = True ,
69
- allow_methods = ["*" ],
70
- allow_headers = ["*" ],
71
- )
65
+
66
+ if settings .ALLOW_CORS :
67
+ app .add_middleware (
68
+ CORSMiddleware ,
69
+ ** settings .CORS_CONFIG ,
70
+ )
72
71
73
72
74
73
@app .exception_handler (Exception )
Original file line number Diff line number Diff line change 1
1
import os
2
2
from typing import Any , Dict
3
3
4
- from pydantic import ConfigDict , model_validator
4
+ from pydantic import ConfigDict , Field , model_validator
5
5
from pydantic_settings import BaseSettings
6
6
7
7
from backend .types import MetadataStoreConfig , VectorDBConfig
@@ -31,6 +31,15 @@ class Settings(BaseSettings):
31
31
LOCAL_DATA_DIRECTORY : str = os .path .abspath (
32
32
os .path .join (os .path .dirname (os .path .dirname (__file__ )), "user_data" )
33
33
)
34
+ ALLOW_CORS : bool = False
35
+ CORS_CONFIG : Dict [str , Any ] = Field (
36
+ default_factory = lambda : {
37
+ "allow_origins" : ["*" ],
38
+ "allow_credentials" : False ,
39
+ "allow_methods" : ["*" ],
40
+ "allow_headers" : ["*" ],
41
+ }
42
+ )
34
43
35
44
@model_validator (mode = "before" )
36
45
@classmethod
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ components:
74
74
UNSTRUCTURED_IO_URL : http://cas-unstructured-io.cognita-internal.svc.cluster.local:8000
75
75
UNSTRUCTURED_IO_API_KEY : tfy-secret://internal:cognita:UNSTRUCTURED_IO_API_KEY
76
76
BRAVE_API_KEY : tfy-secret://internal:cognita:BRAVE_API_KEY
77
+ ALLOW_CORS : " true"
77
78
type : service
78
79
image :
79
80
type : build
You can’t perform that action at this time.
0 commit comments