Skip to content

Commit fd11216

Browse files
authored
Merge pull request #222 from rragundez/fix-settings
Fix duplicated loading of environment variables when collecting settings
2 parents 62a56f1 + ba5f821 commit fd11216

File tree

6 files changed

+128
-117
lines changed

6 files changed

+128
-117
lines changed

docs/getting-started/configuration.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Open `src/.env` and set these required values:
1717
### Application Settings
1818

1919
```env
20-
# App Settings
20+
# App Settings
2121
APP_NAME="Your app name here"
2222
APP_DESCRIPTION="Your app description here"
2323
APP_VERSION="0.1"
@@ -49,9 +49,10 @@ PGADMIN_LISTEN_PORT=80
4949
```
5050

5151
**To connect to database in PGAdmin:**
52+
5253
1. Login with `PGADMIN_DEFAULT_EMAIL` and `PGADMIN_DEFAULT_PASSWORD`
53-
2. Click "Add Server"
54-
3. Use these connection settings:
54+
1. Click "Add Server"
55+
1. Use these connection settings:
5556
- **Hostname/address**: `db` (if using containers) or `localhost`
5657
- **Port**: Value from `POSTGRES_PORT`
5758
- **Database**: `postgres` (leave as default)
@@ -96,7 +97,7 @@ REDIS_CACHE_PORT=6379
9697
CLIENT_CACHE_MAX_AGE=30 # Default: 30 seconds
9798
9899
# Redis Job Queue
99-
REDIS_QUEUE_HOST="localhost" # Use "redis" for Docker Compose
100+
REDIS_QUEUE_HOST="localhost" # Use "redis" for Docker Compose
100101
REDIS_QUEUE_PORT=6379
101102
102103
# Redis Rate Limiting
@@ -105,7 +106,7 @@ REDIS_RATE_LIMIT_PORT=6379
105106
```
106107

107108
!!! warning "Redis in Production"
108-
You may use the same Redis instance for caching and queues while developing, but use separate containers in production.
109+
You may use the same Redis instance for caching and queues while developing, but use separate containers in production.
109110

110111
### Rate Limiting Defaults
111112

@@ -121,18 +122,14 @@ Configure Cross-Origin Resource Sharing for your frontend:
121122

122123
```env
123124
# CORS Settings
124-
CORS_ORIGINS="*" # Comma-separated origins (use specific domains in production)
125-
CORS_METHODS="*" # Comma-separated HTTP methods or "*" for all
126-
CORS_HEADERS="*" # Comma-separated headers or "*" for all
125+
CORS_ORIGINS=["*"] # Comma-separated origins (use specific domains in production)
126+
CORS_METHODS=["*"] # Comma-separated HTTP methods or "*" for all
127+
CORS_HEADERS=["*"] # Comma-separated headers or "*" for all
127128
```
128129

129130
!!! warning "CORS in Production"
130-
Never use `"*"` for CORS_ORIGINS in production. Specify exact domains:
131-
```env
132-
CORS_ORIGINS="https://yourapp.com,https://www.yourapp.com"
133-
CORS_METHODS="GET,POST,PUT,DELETE,PATCH"
134-
CORS_HEADERS="Authorization,Content-Type"
135-
```
131+
Never use `"*"` for CORS_ORIGINS in production. Specify exact domains:
132+
`env CORS_ORIGINS=["https://yourapp.com","https://www.yourapp.com"] CORS_METHODS=["GET","POST","PUT","DELETE","PATCH"] CORS_HEADERS=["Authorization","Content-Type"] `
136133

137134
### First Tier
138135

@@ -170,7 +167,7 @@ REDIS_RATE_LIMIT_HOST="redis"
170167
The boilerplate includes Redis for caching, job queues, and rate limiting. If running locally without Docker, either:
171168

172169
1. **Install Redis** and keep the default settings
173-
2. **Disable Redis services** (see [User Guide - Configuration](../user-guide/configuration/index.md) for details)
170+
1. **Disable Redis services** (see [User Guide - Configuration](../user-guide/configuration/index.md) for details)
174171

175172
## That's It!
176173

@@ -179,4 +176,4 @@ With these basic settings configured, you can start the application:
179176
- **Docker Compose**: `docker compose up`
180177
- **Manual**: `uv run uvicorn src.app.main:app --reload`
181178

182-
For detailed configuration options, advanced settings, and production deployment, see the [User Guide - Configuration](../user-guide/configuration/index.md).
179+
For detailed configuration options, advanced settings, and production deployment, see the [User Guide - Configuration](../user-guide/configuration/index.md).

docs/user-guide/authentication/jwt-tokens.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ REFRESH_TOKEN_EXPIRE_DAYS=7
518518

519519
# Security Headers
520520
SECURE_COOKIES=true
521-
CORS_ORIGINS="http://localhost:3000,https://yourapp.com"
521+
CORS_ORIGINS=["http://localhost:3000","https://yourapp.com"]
522522
```
523523

524524
### Security Configuration

docs/user-guide/configuration/environment-specific.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ SECRET_KEY="staging-secret-key-different-from-production"
148148
ALGORITHM="HS256"
149149
ACCESS_TOKEN_EXPIRE_MINUTES=30
150150
REFRESH_TOKEN_EXPIRE_DAYS=7
151-
CORS_ORIGINS="https://staging.example.com"
152-
CORS_METHODS="GET,POST,PUT,DELETE"
151+
CORS_ORIGINS=["https://staging.example.com"]
152+
CORS_METHODS=["GET","POST","PUT","DELETE"]
153153
154154
# ------------- redis -------------
155155
REDIS_CACHE_HOST="staging-redis.example.com"
@@ -259,9 +259,9 @@ SECRET_KEY="ultra-secure-production-key-generated-with-openssl-rand-hex-32"
259259
ALGORITHM="HS256"
260260
ACCESS_TOKEN_EXPIRE_MINUTES=15 # Shorter for security
261261
REFRESH_TOKEN_EXPIRE_DAYS=3 # Shorter for security
262-
CORS_ORIGINS="https://example.com,https://www.example.com"
263-
CORS_METHODS="GET,POST,PUT,DELETE"
264-
CORS_HEADERS="Authorization,Content-Type"
262+
CORS_ORIGINS=["https://example.com","https://www.example.com"]
263+
CORS_METHODS=["GET","POST","PUT","DELETE"]
264+
CORS_HEADERS=["Authorization","Content-Type"]
265265
266266
# ------------- redis -------------
267267
REDIS_CACHE_HOST="prod-redis.example.com"

docs/user-guide/configuration/environment-variables.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,33 +178,33 @@ Cross-Origin Resource Sharing (CORS) settings for frontend integration:
178178

179179
```env
180180
# ------------- CORS -------------
181-
CORS_ORIGINS="*"
182-
CORS_METHODS="*"
183-
CORS_HEADERS="*"
181+
CORS_ORIGINS=["*"]
182+
CORS_METHODS=["*"]
183+
CORS_HEADERS=["*"]
184184
```
185185

186186
**Variables Explained:**
187187

188-
- `CORS_ORIGINS`: Comma-separated list of allowed origins (e.g., `"https://app.com,https://www.app.com"`)
189-
- `CORS_METHODS`: Comma-separated list of allowed HTTP methods (e.g., `"GET,POST,PUT,DELETE"`)
190-
- `CORS_HEADERS`: Comma-separated list of allowed headers (e.g., `"Authorization,Content-Type"`)
188+
- `CORS_ORIGINS`: Comma-separated list of allowed origins (e.g., `["https://app.com","https://www.app.com"]`)
189+
- `CORS_METHODS`: Comma-separated list of allowed HTTP methods (e.g., `["GET","POST","PUT","DELETE"]`)
190+
- `CORS_HEADERS`: Comma-separated list of allowed headers (e.g., `["Authorization","Content-Type"]`)
191191

192192
**Environment-Specific Values:**
193193

194194
```env
195195
# Development - Allow all origins
196-
CORS_ORIGINS="*"
197-
CORS_METHODS="*"
198-
CORS_HEADERS="*"
196+
CORS_ORIGINS=["*"]
197+
CORS_METHODS=["*"]
198+
CORS_HEADERS=["*"]
199199
200200
# Production - Specific domains only
201-
CORS_ORIGINS="https://yourapp.com,https://www.yourapp.com"
202-
CORS_METHODS="GET,POST,PUT,DELETE,PATCH"
203-
CORS_HEADERS="Authorization,Content-Type,X-Requested-With"
201+
CORS_ORIGINS=["https://yourapp.com","https://www.yourapp.com"]
202+
CORS_METHODS=["GET","POST","PUT","DELETE","PATCH"]
203+
CORS_HEADERS=["Authorization","Content-Type","X-Requested-With"]
204204
```
205205

206206
!!! danger "Security Warning"
207-
Never use wildcard (`*`) for `CORS_ORIGINS` in production environments. Always specify exact allowed domains to prevent unauthorized cross-origin requests.
207+
Never use wildcard (`*`) for `CORS_ORIGINS` in production environments. Always specify exact allowed domains to prevent unauthorized cross-origin requests.
208208

209209
### User Tiers
210210

scripts/local_with_uvicorn/.env.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ CONTACT_NAME="Me"
2020
CONTACT_EMAIL="[email protected]"
2121
LICENSE_NAME="MIT"
2222

23-
# ------------- database -------------
23+
# ------------- database -------------
2424
POSTGRES_USER="postgres"
2525
POSTGRES_PASSWORD=1234
2626
POSTGRES_SERVER="db"
@@ -55,9 +55,9 @@ REDIS_RATE_LIMIT_PORT=6379
5555
CLIENT_CACHE_MAX_AGE=60
5656

5757
# ------------- CORS -------------
58-
CORS_ORIGINS="*"
59-
CORS_METHODS="*"
60-
CORS_HEADERS="*"
58+
CORS_ORIGINS=["*"]
59+
CORS_METHODS=["*"]
60+
CORS_HEADERS=["*"]
6161

6262
# ------------- test -------------
6363
TEST_NAME="Tester User"

0 commit comments

Comments
 (0)