feat: add production deployment for rf4spotter.ru
This commit is contained in:
@@ -34,7 +34,7 @@ logger = logging.getLogger("rf4.api")
|
||||
app = FastAPI(title="RF4 Spotter API", version="0.1.0")
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["http://localhost:4321", "http://127.0.0.1:4321"],
|
||||
allow_origins=settings.cors_origins,
|
||||
allow_methods=["GET", "POST", "PATCH", "DELETE"],
|
||||
allow_headers=["Authorization", "Content-Type"],
|
||||
)
|
||||
@@ -50,6 +50,11 @@ async def structured_request_log(request: Request, call_next):
|
||||
response = await call_next(request)
|
||||
status_code = response.status_code
|
||||
response.headers["X-Request-ID"] = request_id
|
||||
response.headers["X-Content-Type-Options"] = "nosniff"
|
||||
response.headers["Referrer-Policy"] = "strict-origin-when-cross-origin"
|
||||
response.headers["Permissions-Policy"] = "camera=(), microphone=(), geolocation=()"
|
||||
if settings.deployment_environment == "production":
|
||||
response.headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains"
|
||||
return response
|
||||
except Exception as exc:
|
||||
logger.error("request failed", extra={"request_id": request_id, "error_type": type(exc).__name__})
|
||||
|
||||
Reference in New Issue
Block a user