added port to env, added concurrent pkg for windows QOL
This commit is contained in:
parent
dcf86a95fd
commit
4eb8bccbb2
6 changed files with 21 additions and 5 deletions
|
|
@ -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
|
# REQUIRED: Anthropic API Key
|
||||||
REACT_APP_ANTHROPIC_API_KEY=sk-ant-your-key-here
|
REACT_APP_ANTHROPIC_API_KEY=sk-ant-your-key-here
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"proxy": "node proxy-server.js",
|
"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",
|
"build": "vite build",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
|
|
@ -29,6 +30,7 @@
|
||||||
"@types/react": "^19.2.7",
|
"@types/react": "^19.2.7",
|
||||||
"@types/react-dom": "^19.2.3",
|
"@types/react-dom": "^19.2.3",
|
||||||
"@vitejs/plugin-react": "^5.1.1",
|
"@vitejs/plugin-react": "^5.1.1",
|
||||||
|
"concurrently": "^9.2.1",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^9.39.1",
|
||||||
"eslint-plugin-react-hooks": "^7.0.1",
|
"eslint-plugin-react-hooks": "^7.0.1",
|
||||||
"eslint-plugin-react-refresh": "^0.4.24",
|
"eslint-plugin-react-refresh": "^0.4.24",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import express from 'express';
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const PORT = 3001;
|
const PORT = process.env.PROXY_PORT || 5374;
|
||||||
const DEBUG = process.env.REACT_APP_DEBUG_MODE === 'true';
|
const DEBUG = process.env.REACT_APP_DEBUG_MODE === 'true';
|
||||||
|
|
||||||
function debugLog(...args) {
|
function debugLog(...args) {
|
||||||
|
|
|
||||||
|
|
@ -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 })));
|
debugLog('Request messages:', requestBody.messages.map(m => ({ role: m.role, contentLength: m.content.length })));
|
||||||
|
|
||||||
// Use local proxy server instead of direct API call
|
// 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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ export async function parseJSON(url, corsProxy) {
|
||||||
// Route through the local proxy server, which fetches server-side with a proper
|
// Route through the local proxy server, which fetches server-side with a proper
|
||||||
// User-Agent header that Reddit accepts.
|
// User-Agent header that Reddit accepts.
|
||||||
if (url.includes('reddit.com')) {
|
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);
|
const response = await fetch(proxyUrl);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Local proxy returned ${response.status} for Reddit URL`);
|
throw new Error(`Local proxy returned ${response.status} for Reddit URL`);
|
||||||
|
|
@ -130,7 +131,8 @@ export async function parseHTML(url, corsProxy) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Use local proxy server to avoid CORS issues with arbitrary websites
|
// 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);
|
const response = await fetch(proxyUrl);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,12 @@ export default defineConfig(({ mode }) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
|
server: {
|
||||||
|
port: env.PORT || 5173,
|
||||||
|
},
|
||||||
define: {
|
define: {
|
||||||
// Expose all REACT_APP_ prefixed variables
|
// 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_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_DATA_SOURCES': JSON.stringify(env.REACT_APP_DATA_SOURCES),
|
||||||
'import.meta.env.REACT_APP_LOCATION': JSON.stringify(env.REACT_APP_LOCATION),
|
'import.meta.env.REACT_APP_LOCATION': JSON.stringify(env.REACT_APP_LOCATION),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue