Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copy this file to `.env` and adjust values for your local setup.

# Backend Settings
SECUSCAN_DEBUG=true
SECUSCAN_DEBUG=false
SECUSCAN_LOG_LEVEL=INFO
SECUSCAN_BIND_ADDRESS=127.0.0.1
SECUSCAN_BIND_PORT=8000
Expand Down
2 changes: 1 addition & 1 deletion backend/secuscan/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Settings(BaseSettings):
# Server Configuration
bind_address: str = "127.0.0.1"
bind_port: int = 8000
debug: bool = True
debug: bool = False

# Primary data store
database_path: str = str(PROJECT_ROOT / "data" / "secuscan.db")
Expand Down
35 changes: 18 additions & 17 deletions backend/secuscan/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,26 +167,27 @@ async def lifespan(app: FastAPI):
title="SecuScan API",
description="Backend for SecuScan Pentesting Toolkit",
version="1.0.0",
docs_url="/docs",
redoc_url="/redoc",
openapi_url="/openapi.json",
docs_url="/docs" if settings.debug else None,
redoc_url="/redoc" if settings.debug else None,
openapi_url="/openapi.json" if settings.debug else None,
Comment on lines +170 to +172

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve OpenAPI docs for dev startup

When using the documented dev workflow, start.sh invokes python -m uvicorn backend.secuscan.main:app --reload and advertises /docs, but it never exports SECUSCAN_DEBUG and Settings does not load .env automatically. With the new default False, these routes are not registered at import time, so the advertised local Swagger/ReDoc/OpenAPI URLs 404 unless developers know to set SECUSCAN_DEBUG=true manually; use a separate production/docs flag or have the dev launcher explicitly enable debug/docs.

Useful? React with 👍 / 👎.

lifespan=lifespan
)

@app.get("/api/docs", include_in_schema=False)
async def redirect_api_docs():
from fastapi.responses import RedirectResponse
return RedirectResponse(url="/docs")

@app.get("/api/redoc", include_in_schema=False)
async def redirect_api_redoc():
from fastapi.responses import RedirectResponse
return RedirectResponse(url="/redoc")

@app.get("/api/openapi.json", include_in_schema=False)
async def redirect_api_openapi():
from fastapi.responses import RedirectResponse
return RedirectResponse(url="/openapi.json")
if settings.debug:
@app.get("/api/docs", include_in_schema=False)
async def redirect_api_docs():
from fastapi.responses import RedirectResponse
return RedirectResponse(url="/docs")

@app.get("/api/redoc", include_in_schema=False)
async def redirect_api_redoc():
from fastapi.responses import RedirectResponse
return RedirectResponse(url="/redoc")

@app.get("/api/openapi.json", include_in_schema=False)
async def redirect_api_openapi():
from fastapi.responses import RedirectResponse
return RedirectResponse(url="/openapi.json")

# CORS middleware
cors_allow_all = "*" in settings.cors_allowed_origins
Expand Down
2 changes: 2 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ pip install -q -r backend/requirements.txt
mkdir -p "$ROOT_DIR/data" "$ROOT_DIR/logs"

echo "🚀 Starting backend on http://127.0.0.1:8000"
# Dev workflow needs debug=True for /docs, /redoc, and hot-reload
export SECUSCAN_DEBUG=true
python -m uvicorn backend.secuscan.main:app \
--host 127.0.0.1 \
--port 8000 \
Expand Down
Loading