From 8a3d5fd947975591c97d84803018545a29d48867 Mon Sep 17 00:00:00 2001 From: imbytecat Date: Mon, 11 May 2026 23:38:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(env):=20=E8=A6=81=E6=B1=82=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=20SoH=20=E9=A2=84=E6=B5=8B=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 4 ++-- compose.yaml | 3 +++ src/env.ts | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 71f3a4f..932bcec 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ DATABASE_URL=mysql://user:password@localhost:3306/database -# Optional: external AI SoH prediction service. -# SOH_PREDICTION_API_BASE_URL=http://127.0.0.1:8000 +# Required: external AI SoH prediction service. +SOH_PREDICTION_API_BASE_URL=http://127.0.0.1:8000 # SOH_PREDICTION_CACHE_TTL_SECONDS=86400 # SOH_PREDICTION_TIMEOUT_MS=10000 diff --git a/compose.yaml b/compose.yaml index 1f2a40b..fab7fc8 100644 --- a/compose.yaml +++ b/compose.yaml @@ -26,6 +26,7 @@ services: condition: service_healthy environment: - DATABASE_URL=mysql://battery:battery@db:3306/battery_soh + - SOH_PREDICTION_API_BASE_URL=http://host.docker.internal:8000 command: [ "bun", "run", "seed" ] app: @@ -33,6 +34,8 @@ services: depends_on: seed: condition: service_completed_successfully + extra_hosts: + - "host.docker.internal:host-gateway" ports: - "3000:3000" environment: diff --git a/src/env.ts b/src/env.ts index ff614d1..4983a6c 100644 --- a/src/env.ts +++ b/src/env.ts @@ -7,7 +7,7 @@ export const env = createEnv({ LOG_DB: z.stringbool().default(false), LOG_FORMAT: z.enum(['pretty', 'json']).optional(), LOG_LEVEL: z.enum(['trace', 'debug', 'info', 'warning', 'error', 'fatal']).default('info'), - SOH_PREDICTION_API_BASE_URL: z.url({ protocol: /^https?$/ }).optional(), + SOH_PREDICTION_API_BASE_URL: z.url({ protocol: /^https?$/ }), SOH_PREDICTION_CACHE_TTL_SECONDS: z.coerce.number().int().positive().default(86_400), SOH_PREDICTION_TIMEOUT_MS: z.coerce.number().int().positive().default(10_000), },