mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 20:23:36 +00:00
feat: add support for external server mode with Docker integration
- Introduced a new `docker-compose.dev-server.yml` for running the backend API in a container, enabling local Electron to connect to it. - Updated `dev.mjs` to include a new option for launching the Docker server container. - Enhanced the UI application to support external server mode, allowing session-based authentication and adjusting routing logic accordingly. - Added utility functions to check and cache the external server mode status for improved performance. - Updated various components to handle authentication and routing based on the server mode.
This commit is contained in:
@@ -131,6 +131,39 @@ export const isElectronMode = (): boolean => {
|
||||
return api?.isElectron === true || !!api?.getApiKey;
|
||||
};
|
||||
|
||||
// Cached external server mode flag
|
||||
let cachedExternalServerMode: boolean | null = null;
|
||||
|
||||
/**
|
||||
* Check if running in external server mode (Docker API)
|
||||
* In this mode, Electron uses session-based auth like web mode
|
||||
*/
|
||||
export const checkExternalServerMode = async (): Promise<boolean> => {
|
||||
if (cachedExternalServerMode !== null) {
|
||||
return cachedExternalServerMode;
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
const api = window.electronAPI as any;
|
||||
if (api?.isExternalServerMode) {
|
||||
try {
|
||||
cachedExternalServerMode = await api.isExternalServerMode();
|
||||
return cachedExternalServerMode;
|
||||
} catch (error) {
|
||||
logger.warn('Failed to check external server mode:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cachedExternalServerMode = false;
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get cached external server mode (synchronous, returns null if not yet checked)
|
||||
*/
|
||||
export const isExternalServerMode = (): boolean | null => cachedExternalServerMode;
|
||||
|
||||
/**
|
||||
* Initialize API key and server URL for Electron mode authentication.
|
||||
* In web mode, authentication uses HTTP-only cookies instead.
|
||||
|
||||
Reference in New Issue
Block a user