diff --git a/.env.example b/.env.example index 34cccec..eaa6054 100644 --- a/.env.example +++ b/.env.example @@ -36,4 +36,6 @@ GATEWAY_KEY_TTL=2 RABBITMQ_URL=amqp://guest:guest@localhost:5672/ QUEUE_SECRECT_KEY='XXXXXXXXXXXXXXXXX' -QUEUE_SECRECT_KEY_TTL=0.5 \ No newline at end of file +QUEUE_SECRECT_KEY_TTL=0.5 + +CORS_ALLOWED_ORIGINS=http://localhost:3000, ... \ No newline at end of file diff --git a/src/config/cors.py b/src/config/cors.py new file mode 100644 index 0000000..c14298c --- /dev/null +++ b/src/config/cors.py @@ -0,0 +1,3 @@ +from src.env import cors + +CORS_ALLOWED_ORIGINS = cors["allowed_origins"] diff --git a/src/config/settings.py b/src/config/settings.py index e5fcd92..66c0482 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -1,6 +1,7 @@ from src.env import app from .apps import INSTALLED_APPS as INSTALLED_APPS +from .cors import CORS_ALLOWED_ORIGINS as CORS_ALLOWED_ORIGINS from .caches import CACHES as CACHES from .logger import LOGGING as LOGGING from .databases import DATABASES as DATABASES diff --git a/src/env.py b/src/env.py index 8d09112..78ea3a9 100644 --- a/src/env.py +++ b/src/env.py @@ -64,6 +64,10 @@ class Queue(TypedDict): ttl: float +class CORS(TypedDict): + allowed_origins: list[str] + + env = Env() app: App = { @@ -126,10 +130,13 @@ class Queue(TypedDict): rabbitmq_config: RabbitMQ = {"url": get_env_str("RABBITMQ_URL")} +cors: CORS = {"allowed_origins": get_env_list("CORS_ALLOWED_ORIGINS")} + __all__ = [ "api_gateway", "app", "cache", + "cors", "db", "env", "jwt_config",