Skip to content

Commit 6bae0a8

Browse files
authored
Merge pull request #11 from Ifechukwu001:fix/auth
Allowed CORS origins
2 parents c2fe49f + d075ddb commit 6bae0a8

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,11 +130,14 @@ 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

130136
__all__ = [
131137
"api_gateway",
132138
"app",
133139
"cache",
140+
"cors",
134141
"db",
135142
"env",
136143
"jwt_config",

0 commit comments

Comments
 (0)