feat: update environment configuration and enhance development setup
- Added optional DEV_APP_URL and DEV_ALLOWED_ORIGINS to docker-compose.dev-env.yml for improved local development flexibility. - Updated .env.example to reflect new environment variables for development. - Modified backend main.py to support rate limiting on authentication routes and improved CORS handling. - Enhanced deploy-dev.yml to include health checks for the frontend service, ensuring better monitoring during development.
This commit is contained in:
1 parent
d67026e25a
commit
e6a8931da8
5 files changed
+25
-6
No files matched your search
+12
-2
@@ -11,6 +11,9 @@ from fastapi.responses import JSONResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
import os
|
||||
|
||||
from slowapi import _rate_limit_exceeded_handler
|
||||
from slowapi.errors import RateLimitExceeded
|
||||
|
||||
from version import APP_VERSION, BUILD_DATE, DB_SCHEMA_VERSION, MODULE_VERSIONS
|
||||
|
||||
# Run database migrations on startup
|
||||
@@ -22,6 +25,8 @@ except Exception as e:
|
||||
print(f"⚠ Warning: Migration error: {e}")
|
||||
print(" Continuing startup - migrations may need manual intervention")
|
||||
|
||||
from routers.auth import limiter as auth_rate_limiter
|
||||
|
||||
# Initialize FastAPI app
|
||||
app = FastAPI(
|
||||
title="Shinkan Jinkendo API",
|
||||
@@ -29,8 +34,13 @@ app = FastAPI(
|
||||
version=APP_VERSION
|
||||
)
|
||||
|
||||
# CORS Configuration
|
||||
ALLOWED_ORIGINS = os.getenv("ALLOWED_ORIGINS", "http://localhost:3098").split(",")
|
||||
# SlowAPI: Rate Limits auf /api/auth/* (Decorator in routers/auth.py)
|
||||
app.state.limiter = auth_rate_limiter
|
||||
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
|
||||
|
||||
# CORS — kommaseparierte Liste (z. B. https://dev.shinkan… und http://192.168.x.x:3098)
|
||||
_cors_raw = os.getenv("ALLOWED_ORIGINS", "http://localhost:3098")
|
||||
ALLOWED_ORIGINS = [o.strip() for o in _cors_raw.split(",") if o.strip()]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
||||
Reference in new issue
Block a user