Files
telemt-api/web/README.md
T
Denozordec ef98560e9f
Publish telemt-api gateway Docker image / test (push) Successful in 24s
Publish telemt-api gateway Docker image / build-and-push (push) Successful in 1m18s
Add CORS support and Docker configuration for web service
- Added CORS allowed origins in config.compose.yaml to enable cross-origin requests from the web service.
- Updated docker-compose.yml to include a new web service with build context and port mapping for local development.
- Enhanced gateway.go to support additional HTTP methods in CORS responses.
- Updated README.md to document the new web service and its configuration requirements.
2026-03-30 10:31:10 +07:00

57 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Telemt Panel (Web UI)
SvelteKit + shadcn-svelte: обзор флота (`/api/agg/*`), пользователи и IP, панель по каждой ноде через прокси шлюза (`/api/{alias}/…`).
## Переменные окружения
| Переменная | Описание |
| --- | --- |
| `PUBLIC_TELEMT_GATEWAY_URL` | Базовый URL шлюза **telemt-api** без завершающего `/` (например `http://127.0.0.1:8080`). Встраивается в клиент при сборке. |
Скопируйте [.env.example](.env.example) в `.env` и при необходимости измените URL.
## Разработка
```powershell
cd web
npm install
npm run dev
```
Откройте в браузере адрес Vite (по умолчанию `http://localhost:5173`). В конфиге шлюза укажите CORS, например:
```yaml
cors_allowed_origins:
- "http://localhost:5173"
```
## Сборка
```powershell
npm run build
npm run preview # проверка статики
```
## Типы из OpenAPI агрегатов
После изменения [../docs/AGGREGATE_OPENAPI.yaml](../docs/AGGREGATE_OPENAPI.yaml):
```powershell
npm run gen:api
```
## Docker
Сборка образа из каталога `web/`:
```powershell
docker build -t telemt-web:local --build-arg PUBLIC_TELEMT_GATEWAY_URL=http://127.0.0.1:8080 .
```
В [docker-compose.yml](../docker-compose.yml) сервис `web` отдаёт UI на порту **4173**. URL шлюза в образе задаётся **build-arg** (см. compose). Браузер на хосте обращается к шлюзу по `http://127.0.0.1:8080` — при другом адресе пересоберите образ с нужным `PUBLIC_TELEMT_GATEWAY_URL`.
## Ограничения
- Секреты upstream к Telemt задаются на шлюзе (`authorization_env`), не в браузере.
- Mutating CORS: шлюз должен разрешать `POST`, `PATCH`, `DELETE` в preflight (в текущей версии репозитория заголовок `Access-Control-Allow-Methods` это учитывает).