mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 09:13:08 +00:00
feat: add HOSTNAME and VITE_HOSTNAME support for improved server URL configuration
- Introduced `HOSTNAME` environment variable for user-facing URLs, defaulting to localhost. - Updated server and client code to utilize `HOSTNAME` for constructing URLs instead of hardcoded localhost. - Enhanced documentation in CLAUDE.md to reflect new configuration options. - Added `VITE_HOSTNAME` for frontend API URLs, ensuring consistent hostname usage across the application. These changes improve flexibility in server configuration and enhance the user experience by providing accurate URLs.
This commit is contained in:
@@ -167,7 +167,9 @@ Use `resolveModelString()` from `@automaker/model-resolver` to convert model ali
|
|||||||
|
|
||||||
- `ANTHROPIC_API_KEY` - Anthropic API key (or use Claude Code CLI auth)
|
- `ANTHROPIC_API_KEY` - Anthropic API key (or use Claude Code CLI auth)
|
||||||
- `HOST` - Host to bind server to (default: 0.0.0.0)
|
- `HOST` - Host to bind server to (default: 0.0.0.0)
|
||||||
|
- `HOSTNAME` - Hostname for user-facing URLs (default: localhost)
|
||||||
- `PORT` - Server port (default: 3008)
|
- `PORT` - Server port (default: 3008)
|
||||||
- `DATA_DIR` - Data storage directory (default: ./data)
|
- `DATA_DIR` - Data storage directory (default: ./data)
|
||||||
- `ALLOWED_ROOT_DIRECTORY` - Restrict file operations to specific directory
|
- `ALLOWED_ROOT_DIRECTORY` - Restrict file operations to specific directory
|
||||||
- `AUTOMAKER_MOCK_AGENT=true` - Enable mock agent mode for CI testing
|
- `AUTOMAKER_MOCK_AGENT=true` - Enable mock agent mode for CI testing
|
||||||
|
- `VITE_HOSTNAME` - Hostname for frontend API URLs (default: localhost)
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ dotenv.config();
|
|||||||
|
|
||||||
const PORT = parseInt(process.env.PORT || '3008', 10);
|
const PORT = parseInt(process.env.PORT || '3008', 10);
|
||||||
const HOST = process.env.HOST || '0.0.0.0';
|
const HOST = process.env.HOST || '0.0.0.0';
|
||||||
|
const HOSTNAME = process.env.HOSTNAME || 'localhost';
|
||||||
const DATA_DIR = process.env.DATA_DIR || './data';
|
const DATA_DIR = process.env.DATA_DIR || './data';
|
||||||
const ENABLE_REQUEST_LOGGING_DEFAULT = process.env.ENABLE_REQUEST_LOGGING !== 'false'; // Default to true
|
const ENABLE_REQUEST_LOGGING_DEFAULT = process.env.ENABLE_REQUEST_LOGGING !== 'false'; // Default to true
|
||||||
|
|
||||||
@@ -618,16 +619,15 @@ const startServer = (port: number, host: string) => {
|
|||||||
: 'enabled'
|
: 'enabled'
|
||||||
: 'disabled';
|
: 'disabled';
|
||||||
const portStr = port.toString().padEnd(4);
|
const portStr = port.toString().padEnd(4);
|
||||||
const hostDisplay = host === '0.0.0.0' ? 'localhost' : host;
|
|
||||||
logger.info(`
|
logger.info(`
|
||||||
╔═══════════════════════════════════════════════════════╗
|
╔═══════════════════════════════════════════════════════╗
|
||||||
║ Automaker Backend Server ║
|
║ Automaker Backend Server ║
|
||||||
╠═══════════════════════════════════════════════════════╣
|
╠═══════════════════════════════════════════════════════╣
|
||||||
║ Listening: ${host}:${port}${' '.repeat(Math.max(0, 34 - host.length - port.toString().length))}║
|
║ Listening: ${host}:${port}${' '.repeat(Math.max(0, 34 - host.length - port.toString().length))}║
|
||||||
║ HTTP API: http://${hostDisplay}:${portStr} ║
|
║ HTTP API: http://${HOSTNAME}:${portStr} ║
|
||||||
║ WebSocket: ws://${hostDisplay}:${portStr}/api/events ║
|
║ WebSocket: ws://${HOSTNAME}:${portStr}/api/events ║
|
||||||
║ Terminal: ws://${hostDisplay}:${portStr}/api/terminal/ws ║
|
║ Terminal: ws://${HOSTNAME}:${portStr}/api/terminal/ws ║
|
||||||
║ Health: http://${hostDisplay}:${portStr}/api/health ║
|
║ Health: http://${HOSTNAME}:${portStr}/api/health ║
|
||||||
║ Terminal: ${terminalStatus.padEnd(37)}║
|
║ Terminal: ${terminalStatus.padEnd(37)}║
|
||||||
╚═══════════════════════════════════════════════════════╝
|
╚═══════════════════════════════════════════════════════╝
|
||||||
`);
|
`);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export function createGetDevServerLogsHandler() {
|
|||||||
result: {
|
result: {
|
||||||
worktreePath: result.result.worktreePath,
|
worktreePath: result.result.worktreePath,
|
||||||
port: result.result.port,
|
port: result.result.port,
|
||||||
|
url: result.result.url,
|
||||||
logs: result.result.logs,
|
logs: result.result.logs,
|
||||||
startedAt: result.result.startedAt,
|
startedAt: result.result.startedAt,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -379,10 +379,11 @@ class DevServerService {
|
|||||||
|
|
||||||
// Create server info early so we can reference it in handlers
|
// Create server info early so we can reference it in handlers
|
||||||
// We'll add it to runningServers after verifying the process started successfully
|
// We'll add it to runningServers after verifying the process started successfully
|
||||||
|
const hostname = process.env.HOSTNAME || 'localhost';
|
||||||
const serverInfo: DevServerInfo = {
|
const serverInfo: DevServerInfo = {
|
||||||
worktreePath,
|
worktreePath,
|
||||||
port,
|
port,
|
||||||
url: `http://localhost:${port}`,
|
url: `http://${hostname}:${port}`,
|
||||||
process: devProcess,
|
process: devProcess,
|
||||||
startedAt: new Date(),
|
startedAt: new Date(),
|
||||||
scrollbackBuffer: '',
|
scrollbackBuffer: '',
|
||||||
@@ -474,7 +475,7 @@ class DevServerService {
|
|||||||
result: {
|
result: {
|
||||||
worktreePath,
|
worktreePath,
|
||||||
port,
|
port,
|
||||||
url: `http://localhost:${port}`,
|
url: `http://${hostname}:${port}`,
|
||||||
message: `Dev server started on port ${port}`,
|
message: `Dev server started on port ${port}`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -594,6 +595,7 @@ class DevServerService {
|
|||||||
result?: {
|
result?: {
|
||||||
worktreePath: string;
|
worktreePath: string;
|
||||||
port: number;
|
port: number;
|
||||||
|
url: string;
|
||||||
logs: string;
|
logs: string;
|
||||||
startedAt: string;
|
startedAt: string;
|
||||||
};
|
};
|
||||||
@@ -613,6 +615,7 @@ class DevServerService {
|
|||||||
result: {
|
result: {
|
||||||
worktreePath: server.worktreePath,
|
worktreePath: server.worktreePath,
|
||||||
port: server.port,
|
port: server.port,
|
||||||
|
url: server.url,
|
||||||
logs: server.scrollbackBuffer,
|
logs: server.scrollbackBuffer,
|
||||||
startedAt: server.startedAt.toISOString(),
|
startedAt: server.startedAt.toISOString(),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export function useDevServerLogs({ worktreePath, autoSubscribe = true }: UseDevS
|
|||||||
isRunning: true,
|
isRunning: true,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
port: result.result!.port,
|
port: result.result!.port,
|
||||||
url: `http://localhost:${result.result!.port}`,
|
url: result.result!.url,
|
||||||
startedAt: result.result!.startedAt,
|
startedAt: result.result!.startedAt,
|
||||||
error: null,
|
error: null,
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -157,7 +157,9 @@ const getServerUrl = (): string => {
|
|||||||
const envUrl = import.meta.env.VITE_SERVER_URL;
|
const envUrl = import.meta.env.VITE_SERVER_URL;
|
||||||
if (envUrl) return envUrl;
|
if (envUrl) return envUrl;
|
||||||
}
|
}
|
||||||
return 'http://localhost:3008';
|
// Use VITE_HOSTNAME if set, otherwise default to localhost
|
||||||
|
const hostname = import.meta.env.VITE_HOSTNAME || 'localhost';
|
||||||
|
return `http://${hostname}:3008`;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -557,6 +559,7 @@ export interface DevServerLogsResponse {
|
|||||||
result?: {
|
result?: {
|
||||||
worktreePath: string;
|
worktreePath: string;
|
||||||
port: number;
|
port: number;
|
||||||
|
url: string;
|
||||||
logs: string;
|
logs: string;
|
||||||
startedAt: string;
|
startedAt: string;
|
||||||
};
|
};
|
||||||
|
|||||||
1
apps/ui/src/types/electron.d.ts
vendored
1
apps/ui/src/types/electron.d.ts
vendored
@@ -994,6 +994,7 @@ export interface WorktreeAPI {
|
|||||||
result?: {
|
result?: {
|
||||||
worktreePath: string;
|
worktreePath: string;
|
||||||
port: number;
|
port: number;
|
||||||
|
url: string;
|
||||||
logs: string;
|
logs: string;
|
||||||
startedAt: string;
|
startedAt: string;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user