chore: configurable host (#247)
* make host configurable * update host var name
This commit is contained in:
committed by
GitHub
parent
ddc692fa77
commit
3ed807f327
@@ -86,6 +86,7 @@ The following environment variables can be configured at build time or runtime:
|
||||
| `POSTHOG_API_ENDPOINT` | Build-time | Empty | PostHog analytics endpoint (disables analytics if empty) |
|
||||
| `BACKEND_PORT` | Runtime | `0` (auto-assign) | Backend server port |
|
||||
| `FRONTEND_PORT` | Runtime | `3000` | Frontend development server port |
|
||||
| `HOST` | Runtime | `127.0.0.1` | Backend server host |
|
||||
| `DISABLE_WORKTREE_ORPHAN_CLEANUP` | Runtime | Not set | Disable git worktree cleanup (for debugging) |
|
||||
|
||||
**Build-time variables** must be set when running `pnpm run build`. **Runtime variables** are read when the application starts.
|
||||
|
||||
@@ -233,10 +233,11 @@ fn main() -> anyhow::Result<()> {
|
||||
0
|
||||
}); // Use 0 to find free port if no specific port provided
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(format!("127.0.0.1:{port}")).await?;
|
||||
let host = std::env::var("HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
|
||||
let listener = tokio::net::TcpListener::bind(format!("{host}:{port}")).await?;
|
||||
let actual_port = listener.local_addr()?.port(); // get → 53427 (example)
|
||||
|
||||
tracing::info!("Server running on http://127.0.0.1:{actual_port}");
|
||||
tracing::info!("Server running on http://{host}:{actual_port}");
|
||||
|
||||
if !cfg!(debug_assertions) {
|
||||
tracing::info!("Opening browser...");
|
||||
|
||||
Reference in New Issue
Block a user