added port to env, added concurrent pkg for windows QOL

This commit is contained in:
Drew Peifer 2026-03-01 13:14:57 -05:00
parent dcf86a95fd
commit 4eb8bccbb2
6 changed files with 21 additions and 5 deletions

View file

@ -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

View file

@ -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",

View file

@ -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) {

View file

@ -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',

View file

@ -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) {

View file

@ -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),