From 9613bddc6092fd270ecf32a67fe5c2c345727f95 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Thu, 19 Mar 2026 17:42:17 +0100 Subject: [PATCH] docs: add UI dev instructions and configurable API proxy target Co-Authored-By: Claude Opus 4.6 (1M context) --- ui/README.md | 91 +++++++++++++---------------------------------- ui/vite.config.ts | 7 +++- 2 files changed, 31 insertions(+), 67 deletions(-) diff --git a/ui/README.md b/ui/README.md index 7dbf7ebf..d77bfe77 100644 --- a/ui/README.md +++ b/ui/README.md @@ -1,73 +1,32 @@ -# React + TypeScript + Vite +# Cameleer3 UI -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. +React SPA built with [@cameleer/design-system](https://gitea.siegeln.net/cameleer/design-system), TanStack Query, and Zustand. -Currently, two official plugins are available: +## Development -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs) -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) - -## React Compiler - -The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). - -## Expanding the ESLint configuration - -If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: - -```js -export default defineConfig([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... - - // Remove tseslint.configs.recommended and replace with this - tseslint.configs.recommendedTypeChecked, - // Alternatively, use this for stricter rules - tseslint.configs.strictTypeChecked, - // Optionally, add this for stylistic rules - tseslint.configs.stylisticTypeChecked, - - // Other configs... - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) +```bash +npm install +npm run dev ``` -You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: +By default the dev server proxies `/api/*` to `http://localhost:8081`. To proxy to a remote server instead: -```js -// eslint.config.js -import reactX from 'eslint-plugin-react-x' -import reactDom from 'eslint-plugin-react-dom' - -export default defineConfig([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... - // Enable lint rules for React - reactX.configs['recommended-typescript'], - // Enable lint rules for React DOM - reactDom.configs.recommended, - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) +```bash +VITE_API_TARGET=http://192.168.50.86:30090 npm run dev +``` + +No CORS issues — Vite's proxy makes API calls server-side. + +## Build + +```bash +npm run build +``` + +## API Types + +Regenerate TypeScript types from a running backend: + +```bash +npm run generate-api:live ``` diff --git a/ui/vite.config.ts b/ui/vite.config.ts index 12c4b2c5..38e2a590 100644 --- a/ui/vite.config.ts +++ b/ui/vite.config.ts @@ -1,13 +1,18 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; +// Use VITE_API_TARGET to proxy to a remote server, e.g.: +// VITE_API_TARGET=https://api.cameleer.siegeln.net npm run dev +const apiTarget = process.env.VITE_API_TARGET || 'http://localhost:8081'; + export default defineConfig({ plugins: [react()], server: { proxy: { '/api': { - target: 'http://localhost:8081', + target: apiTarget, changeOrigin: true, + secure: false, }, }, },