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:
@@ -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")
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user