Skip to content

Commit 0241529

Browse files
authored
Merge pull request #14 from Ifechukwu001:fix/auth
Allowed CORS origins
2 parents e7d9a6f + 73b1b9a commit 0241529

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ GATEWAY_KEY_TTL=2
3636
RABBITMQ_URL=amqp://guest:guest@localhost:5672/
3737

3838
QUEUE_SECRECT_KEY='XXXXXXXXXXXXXXXXX'
39-
QUEUE_SECRECT_KEY_TTL=0.5
39+
QUEUE_SECRECT_KEY_TTL=0.5
40+
41+
CORS_ALLOWED_ORIGINS=http://localhost:3000, ...

src/config/cors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from src.env import cors
2+
3+
CORS_ALLOWED_ORIGINS = cors["allowed_origins"]

src/config/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from src.env import app
22

33
from .apps import INSTALLED_APPS as INSTALLED_APPS
4+
from .cors import CORS_ALLOWED_ORIGINS as CORS_ALLOWED_ORIGINS
45
from .caches import CACHES as CACHES
56
from .logger import LOGGING as LOGGING
67
from .databases import DATABASES as DATABASES

src/env.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ class Queue(TypedDict):
6464
ttl: float
6565

6666

67+
class CORS(TypedDict):
68+
allowed_origins: list[str]
69+
70+
6771
env = Env()
6872

6973
app: App = {
@@ -126,10 +130,13 @@ class Queue(TypedDict):
126130

127131
rabbitmq_config: RabbitMQ = {"url": get_env_str("RABBITMQ_URL")}
128132

133+
cors: CORS = {"allowed_origins": get_env_list("CORS_ALLOWED_ORIGINS")}
134+
129135
__all__ = [
130136
"api_gateway",
131137
"app",
132138
"cache",
139+
"cors",
133140
"db",
134141
"env",
135142
"jwt_config",

0 commit comments

Comments
 (0)