From 0bcf39bb4bfdf5b0b4c811be3eefef0ef443a6b6 Mon Sep 17 00:00:00 2001 From: congsh Date: Fri, 17 Apr 2026 19:51:12 +0800 Subject: [PATCH] fix: resolve /api/api doubled path in Docker deployment - Remove VITE_PB_URL=/api from Dockerfile (SDK auto-appends /api) - Fix nginx proxy_pass to keep /api/ prefix for PocketBase - Update pocketbase.ts fallback to window.location.origin - Update PocketBase proxy target to port 8090 Co-Authored-By: Claude Opus 4.7 --- frontend/Dockerfile | 2 +- frontend/nginx.conf | 2 +- frontend/src/api/pocketbase.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index c3f4824..71edcec 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -11,7 +11,7 @@ RUN npm ci COPY . . # 设置构建参数并构建(默认使用相对路径,由 nginx 代理) -ARG VITE_PB_URL=/api +ARG VITE_PB_URL= ENV VITE_PB_URL=$VITE_PB_URL RUN npm run build diff --git a/frontend/nginx.conf b/frontend/nginx.conf index d92ef32..c4eb609 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -14,7 +14,7 @@ server { # API 代理到局域网 PocketBase location /api/ { - proxy_pass http://192.168.1.14:8711/; + proxy_pass http://192.168.1.14:8090; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; diff --git a/frontend/src/api/pocketbase.ts b/frontend/src/api/pocketbase.ts index dfa679c..86018b8 100644 --- a/frontend/src/api/pocketbase.ts +++ b/frontend/src/api/pocketbase.ts @@ -1,7 +1,7 @@ // src/api/pocketbase.ts import PocketBase from 'pocketbase' -const pbUrl = import.meta.env.VITE_PB_URL || 'http://localhost:8090' +const pbUrl = import.meta.env.VITE_PB_URL || window.location.origin export const pb = new PocketBase(pbUrl)