From 4eb8bccbb24b41e835aaf8c7e3548ba7bb54bed7 Mon Sep 17 00:00:00 2001 From: Drew Peifer Date: Sun, 1 Mar 2026 13:14:57 -0500 Subject: [PATCH] added port to env, added concurrent pkg for windows QOL --- claudash/.env.example | 7 +++++++ claudash/package.json | 4 +++- claudash/proxy-server.js | 2 +- claudash/src/services/claudeService.js | 3 ++- claudash/src/services/sourceParser.js | 6 ++++-- claudash/vite.config.js | 4 ++++ 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/claudash/.env.example b/claudash/.env.example index 26ef726..b5b08b6 100644 --- a/claudash/.env.example +++ b/claudash/.env.example @@ -1,3 +1,10 @@ +# Vite dev server port (default: 5173) +PORT=5173 + +# Proxy server port (default: 5374) +REACT_APP_PROXY_PORT=5374 +PROXY_PORT=5374 + # REQUIRED: Anthropic API Key REACT_APP_ANTHROPIC_API_KEY=sk-ant-your-key-here diff --git a/claudash/package.json b/claudash/package.json index 4a37f74..1e71615 100644 --- a/claudash/package.json +++ b/claudash/package.json @@ -6,7 +6,8 @@ "scripts": { "dev": "vite", "proxy": "node proxy-server.js", - "start": "npm run proxy & npm run dev", + "start": "concurrently \"npm run proxy\" \"npm run dev\"", + "start:win": "start /B npm run proxy && npm run dev", "build": "vite build", "lint": "eslint .", "preview": "vite preview" @@ -29,6 +30,7 @@ "@types/react": "^19.2.7", "@types/react-dom": "^19.2.3", "@vitejs/plugin-react": "^5.1.1", + "concurrently": "^9.2.1", "eslint": "^9.39.1", "eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-refresh": "^0.4.24", diff --git a/claudash/proxy-server.js b/claudash/proxy-server.js index 5d9c986..c8979d1 100644 --- a/claudash/proxy-server.js +++ b/claudash/proxy-server.js @@ -2,7 +2,7 @@ import express from 'express'; import cors from 'cors'; const app = express(); -const PORT = 3001; +const PORT = process.env.PROXY_PORT || 5374; const DEBUG = process.env.REACT_APP_DEBUG_MODE === 'true'; function debugLog(...args) { diff --git a/claudash/src/services/claudeService.js b/claudash/src/services/claudeService.js index dcbf59a..59395d3 100644 --- a/claudash/src/services/claudeService.js +++ b/claudash/src/services/claudeService.js @@ -43,7 +43,8 @@ async function callClaude(prompt, messages = [], tools = null) { debugLog('Request messages:', requestBody.messages.map(m => ({ role: m.role, contentLength: m.content.length }))); // Use local proxy server instead of direct API call - const response = await fetch('http://localhost:3001/api/claude', { + const proxyPort = import.meta.env.REACT_APP_PROXY_PORT || '5374'; + const response = await fetch(`http://localhost:${proxyPort}/api/claude`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/claudash/src/services/sourceParser.js b/claudash/src/services/sourceParser.js index 769bddc..5ffc9f7 100644 --- a/claudash/src/services/sourceParser.js +++ b/claudash/src/services/sourceParser.js @@ -30,7 +30,8 @@ export async function parseJSON(url, corsProxy) { // Route through the local proxy server, which fetches server-side with a proper // User-Agent header that Reddit accepts. if (url.includes('reddit.com')) { - const proxyUrl = `http://localhost:3001/api/scrape?url=${encodeURIComponent(url)}`; + const proxyPort = import.meta.env.REACT_APP_PROXY_PORT || '5374'; + const proxyUrl = `http://localhost:${proxyPort}/api/scrape?url=${encodeURIComponent(url)}`; const response = await fetch(proxyUrl); if (!response.ok) { throw new Error(`Local proxy returned ${response.status} for Reddit URL`); @@ -130,7 +131,8 @@ export async function parseHTML(url, corsProxy) { try { // Use local proxy server to avoid CORS issues with arbitrary websites - const proxyUrl = `http://localhost:3001/api/scrape?url=${encodeURIComponent(url)}`; + const proxyPort = import.meta.env.REACT_APP_PROXY_PORT || '5374'; + const proxyUrl = `http://localhost:${proxyPort}/api/scrape?url=${encodeURIComponent(url)}`; const response = await fetch(proxyUrl); if (!response.ok) { diff --git a/claudash/vite.config.js b/claudash/vite.config.js index 091b291..38bc867 100644 --- a/claudash/vite.config.js +++ b/claudash/vite.config.js @@ -21,8 +21,12 @@ export default defineConfig(({ mode }) => { return { plugins: [react()], + server: { + port: env.PORT || 5173, + }, define: { // Expose all REACT_APP_ prefixed variables + 'import.meta.env.REACT_APP_PROXY_PORT': JSON.stringify(env.REACT_APP_PROXY_PORT), 'import.meta.env.REACT_APP_ANTHROPIC_API_KEY': JSON.stringify(env.REACT_APP_ANTHROPIC_API_KEY), 'import.meta.env.REACT_APP_DATA_SOURCES': JSON.stringify(env.REACT_APP_DATA_SOURCES), 'import.meta.env.REACT_APP_LOCATION': JSON.stringify(env.REACT_APP_LOCATION),