Add host configuration for backend server and update documentation

- Introduced a new `host` option in `flake.nix` to specify the server's bind address, defaulting to `0.0.0.0`.
- Updated `run.sh` to use the `HOST` environment variable for server binding.
- Modified `config.py` to read the `HOST` from environment variables, defaulting to `0.0.0.0`.
- Enhanced `README.md` with instructions for setting up the `HOST` variable and clarified access details for development and production modes.
- Adjusted `vite.config.ts` to allow frontend access from other computers by default.
This commit is contained in:
Danilo Reyes
2025-12-28 21:20:21 -06:00
parent 96fcc2b9e8
commit 98622c4119
5 changed files with 63 additions and 16 deletions

View File

@@ -9,7 +9,7 @@ class Settings(BaseSettings):
# Server
port: int = int(os.getenv("PORT", "8080"))
host: str = "127.0.0.1"
host: str = os.getenv("HOST", "0.0.0.0") # Default to all interfaces
# Database
postgres_socket_path: str = os.getenv("POSTGRES_SOCKET_PATH", "/run/postgresql")

View File

@@ -5,6 +5,7 @@ cd "$(dirname "$0")"
# Default values
export PORT=${PORT:-8080}
export HOST=${HOST:-0.0.0.0} # Bind to all interfaces by default
export POSTGRES_SOCKET_PATH=${POSTGRES_SOCKET_PATH:-/run/postgresql}
export POSTGRES_DB=${POSTGRES_DB:-jawz}
@@ -31,5 +32,5 @@ if [ -d "alembic/versions" ]; then
fi
# Start the server
exec uvicorn main:app --host 127.0.0.1 --port "$PORT"
exec uvicorn main:app --host "$HOST" --port "$PORT"