From 10b7f0ed7b6dfc14ddf862a06b8a6c6a13b6c7ad Mon Sep 17 00:00:00 2001 From: seb Date: Wed, 2 Jul 2025 13:21:08 +0200 Subject: [PATCH] Add proxy target configuration and new start script for seedheads dev mode --- README.md | 13 +++++++++++++ package.json | 1 + src/pages/Home.js | 1 + start-dev-seedheads.bat | 41 +++++++++++++++++++++++++++++++++++++++++ webpack.config.js | 11 +++++++---- 5 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 README.md create mode 100644 start-dev-seedheads.bat diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0defe8 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# Schnellstart + +## Voraussetzungen + +1. **Node.js herunterladen**: [nodejs.org](https://nodejs.org) - LTS-Version installieren +2. **VSCode herunterladen**: [code.visualstudio.com](https://code.visualstudio.com) - Stabile Version installieren + +[ZIP herunterladen](https://github.com/Growheads-de/shopFrontEnd/archive/refs/heads/live.zip) + +Entpacken & Doppelklick auf `start-dev-seedheads.bat` - das Skript wird: +- Abhängigkeiten automatisch installieren falls nötig +- Entwicklungsserver mit API-Proxy zu seedheads.de starten +- Browser öffnen auf http://localhost:9500 diff --git a/package.json b/package.json index debfc57..89a680b 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "index.js", "scripts": { "start": "webpack serve --progress --mode development --no-open", + "start:seedheads": "cross-env PROXY_TARGET=https://seedheads.de webpack serve --progress --mode development --no-open", "prod": "webpack serve --progress --mode production --no-client-overlay --no-client --no-web-socket-server --no-open --no-live-reload --no-hot --compress --no-devtool", "build:client": "cross-env NODE_ENV=production webpack --progress --mode production && shx cp dist/index.html dist/index_template.html", "build": "npm run build:client", diff --git a/src/pages/Home.js b/src/pages/Home.js index c63d1d8..275ae45 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -372,6 +372,7 @@ const Home = () => { animationIdRef.current = requestAnimationFrame(animate); }, 3000); }; + return ( diff --git a/start-dev-seedheads.bat b/start-dev-seedheads.bat new file mode 100644 index 0000000..ec0c46f --- /dev/null +++ b/start-dev-seedheads.bat @@ -0,0 +1,41 @@ +@echo off +echo Starting ReactShop Development Server with Seedheads.de API Proxy... +echo. + +REM Check if node_modules directory exists +if not exist "node_modules" ( + echo node_modules directory not found. Installing dependencies... + echo. + npm install . + if errorlevel 1 ( + echo. + echo ERROR: npm install failed! + pause + exit /b 1 + ) + echo. + echo Dependencies installed successfully! + echo. +) else ( + echo node_modules found, skipping installation. + echo. +) + +REM Start the development server +echo Starting development server with Seedheads.de proxy... +echo Server will be available at: http://localhost:9500 +echo API calls will be proxied to: https://seedheads.de +echo Press Ctrl+C to stop the server +echo. + +REM Wait a moment then open Chrome +timeout /t 3 /nobreak >nul +start "" "C:\Program Files\Google\Chrome\Application\chrome.exe" "http://localhost:9500" + +REM Start the npm server (this will block until stopped) +npm run start:seedheads + +REM This will only execute if the server is stopped +echo. +echo Development server stopped. +pause \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index f031717..36a7573 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -91,6 +91,7 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const isDevelopment = process.env.NODE_ENV !== 'production'; const isAnalyze = process.env.ANALYZE === 'true'; +const proxyTarget = process.env.PROXY_TARGET || 'http://localhost:9303'; export default { mode: isDevelopment ? 'development' : 'production', @@ -267,16 +268,18 @@ export default { proxy: [ { context: ['/socket.io'], - target: 'http://localhost:9303', + target: proxyTarget, changeOrigin: true, ws: true, - logLevel: 'debug' + logLevel: 'debug', + secure: proxyTarget.startsWith('https') }, { context: ['/api'], - target: 'http://localhost:9303', + target: proxyTarget, changeOrigin: true, - logLevel: 'debug' + logLevel: 'debug', + secure: proxyTarget.startsWith('https') } ], setupMiddlewares: (middlewares, devServer) => {