From f4ca680532848dc6a82fbc7c4fda45983efccc7e Mon Sep 17 00:00:00 2001 From: "nasir@endelospay.com" Date: Fri, 22 Aug 2025 00:21:10 +0500 Subject: [PATCH] feat: add PM2 configuration and deployment setup for remote server - Add Makefile with convenient PM2 commands for development and production - Add ecosystem.config.js with production/staging/dev environment configurations - Add comprehensive PM2-GUIDE.md documentation for deployment - Update package.json with PM2-specific npm scripts - Fix Chrome extension URL handling to omit standard ports (443/80) - Hide embedding model and semantic engine sections in popup UI --- app/chrome-extension/common/env-config.ts | 39 +++- .../entrypoints/popup/App.vue | 4 +- app/remote-server/Makefile | 110 +++++++++ app/remote-server/PM2-GUIDE.md | 213 ++++++++++++++++++ app/remote-server/ecosystem.config.js | 95 ++++++++ app/remote-server/package.json | 10 +- 6 files changed, 466 insertions(+), 5 deletions(-) create mode 100644 app/remote-server/Makefile create mode 100644 app/remote-server/PM2-GUIDE.md create mode 100644 app/remote-server/ecosystem.config.js diff --git a/app/chrome-extension/common/env-config.ts b/app/chrome-extension/common/env-config.ts index 7ba94ea..66b687d 100644 --- a/app/chrome-extension/common/env-config.ts +++ b/app/chrome-extension/common/env-config.ts @@ -15,12 +15,47 @@ console.log('Environment Config Loaded:', { REMOTE_SERVER_PORT, }); +// Helper function to determine if we should include port in URL +const shouldIncludePort = (host: string, port: string): boolean => { + // For localhost/127.0.0.1, always include port + if (host === '127.0.0.1' || host === 'localhost') { + return true; + } + + // For HTTPS domains using standard port 443, don't include port + if (port === '443') { + return false; + } + + // For HTTP domains using standard port 80, don't include port + if (port === '80') { + return false; + } + + // For all other cases, include the port + return true; +}; + +// Helper function to determine protocol +const getProtocol = (port: string): { ws: string; http: string } => { + if (port === '443') { + return { ws: 'wss', http: 'https' }; + } + return { ws: 'ws', http: 'http' }; +}; + +// Build URLs based on whether port should be included +const includePort = shouldIncludePort(REMOTE_SERVER_HOST, REMOTE_SERVER_PORT); +const protocols = getProtocol(REMOTE_SERVER_PORT); + +const baseUrl = includePort ? `${REMOTE_SERVER_HOST}:${REMOTE_SERVER_PORT}` : REMOTE_SERVER_HOST; + // Remote Server Configuration export const REMOTE_SERVER_CONFIG = { HOST: REMOTE_SERVER_HOST, PORT: REMOTE_SERVER_PORT, - WS_URL: `ws://${REMOTE_SERVER_HOST}:${REMOTE_SERVER_PORT}/chrome`, - HTTP_URL: `http://${REMOTE_SERVER_HOST}:${REMOTE_SERVER_PORT}/mcp`, + WS_URL: `${protocols.ws}://${baseUrl}/chrome`, + HTTP_URL: `${protocols.http}://${baseUrl}/mcp`, } as const; // Default connection settings diff --git a/app/chrome-extension/entrypoints/popup/App.vue b/app/chrome-extension/entrypoints/popup/App.vue index a6b15b0..30275dd 100644 --- a/app/chrome-extension/entrypoints/popup/App.vue +++ b/app/chrome-extension/entrypoints/popup/App.vue @@ -384,7 +384,7 @@ -
+