cors - open api

This commit is contained in:
CarterPerez-dev 2026-01-06 13:39:36 -05:00
parent e4501c6697
commit 835a24c2ec
3 changed files with 19 additions and 11 deletions

View File

@ -72,12 +72,12 @@ REFRESH_TOKEN_EXPIRE_DAYS=7
ADMIN_EMAIL= ADMIN_EMAIL=
# ============================================================================= # =============================================================================
# CORS (must match HOST PORTS above!) # CORS
# ============================================================================= # =============================================================================
# Format: http://localhost:<NGINX_HOST_PORT>,http://localhost:<FRONTEND_HOST_PORT> # Use ["*"] to allow all origins (public API)
# Update these if you change the host ports above # Or specify origins: ["http://localhost:8420","http://localhost:3420"]
CORS_ORIGINS=http://localhost,http://localhost:8420,http://localhost:3420 CORS_ORIGINS=["*"]
# ============================================================================= # =============================================================================
# Rate Limiting # Rate Limiting

View File

@ -258,6 +258,7 @@ All configuration is done via `.env` file. Key variables:
| `ENVIRONMENT` | dev/staging/production | development | | `ENVIRONMENT` | dev/staging/production | development |
| `ACCESS_TOKEN_EXPIRE_MINUTES` | JWT access token lifetime | 15 | | `ACCESS_TOKEN_EXPIRE_MINUTES` | JWT access token lifetime | 15 |
| `REFRESH_TOKEN_EXPIRE_DAYS` | Refresh token lifetime | 7 | | `REFRESH_TOKEN_EXPIRE_DAYS` | Refresh token lifetime | 7 |
| `CORS_ORIGINS` | Allowed origins for CORS | `["*"]` (all origins) |
See `.env.example` for all available options. See `.env.example` for all available options.
@ -271,9 +272,20 @@ BACKEND_HOST_PORT=5420 # Change to any available port
FRONTEND_HOST_PORT=3420 # Change to any available port FRONTEND_HOST_PORT=3420 # Change to any available port
POSTGRES_HOST_PORT=4420 # Change to any available port POSTGRES_HOST_PORT=4420 # Change to any available port
REDIS_HOST_PORT=6420 # Change to any available port REDIS_HOST_PORT=6420 # Change to any available port
```
# IMPORTANT: Update CORS_ORIGINS to match NGINX_HOST_PORT ### CORS Configuration
CORS_ORIGINS=http://localhost,http://localhost:8420,http://localhost:3420
The API is configured to accept requests from **all origins** by default:
```bash
CORS_ORIGINS=["*"] # Allows all origins (public API)
```
If you need to restrict access to specific origins:
```bash
CORS_ORIGINS=["https://yourdomain.com","https://app.yourdomain.com"]
``` ```
--- ---

View File

@ -158,11 +158,7 @@ class Settings(BaseSettings):
REDIS_URL: RedisDsn | None = None REDIS_URL: RedisDsn | None = None
CORS_ORIGINS: list[str] = [ CORS_ORIGINS: list[str] = ["*"]
"http://localhost",
"http://localhost:3420",
"http://localhost:8420",
]
CORS_ALLOW_CREDENTIALS: bool = True CORS_ALLOW_CREDENTIALS: bool = True
CORS_ALLOW_METHODS: list[str] = [ CORS_ALLOW_METHODS: list[str] = [
"GET", "GET",