merge(dev_jacy): local API port 3010

This commit is contained in:
2026-08-07 21:03:59 +08:00
13 changed files with 18 additions and 16 deletions
@@ -13,7 +13,7 @@
> **h5-partner 与 admin-web 端口同为 5175**,勿同时 `dev:partner` + `dev:admin`。
Vite 代理:`/api``localhost:3000`
Vite 代理:`/api``localhost:3010`(可用 `VITE_API_TARGET` 覆盖)
## 共享包
+2 -2
View File
@@ -28,7 +28,7 @@ pnpm db:generate && pnpm db:validate
cd server/dukang-api && npx prisma db push && pnpm prisma:seed
# 开发(分终端)
pnpm dev:api # http://localhost:3000/api/v1
pnpm dev:api # http://localhost:3010/api/v1
pnpm dev:user # :5173
pnpm dev:shop # :5174
pnpm dev:partner # :5175
@@ -144,7 +144,7 @@ C 端门店仅 status=OPEN
| 环境 | 分支 | 目录 | 端口 | 域名 |
|------|------|------|------|------|
| local | `dev_jacy` | 本机 Docker 6016/6017 | API `:3000` | — |
| local | `dev_jacy` | 本机 Docker 6016/6017 | API `:3010` | — |
| **staging 测试** | `dev` | `/opt/dukang-staging` | 81908194 | `*-test.dukanghaoke.com` |
| **production 生产** | `main` | `/opt/dukang` | 80908094 | `*.dukanghaoke.com` |
+3 -1
View File
@@ -1,10 +1,12 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
const apiTarget = process.env.VITE_API_TARGET ?? 'http://localhost:3010';
export default defineConfig({
plugins: [react()],
server: {
port: 5175,
proxy: { '/api': 'http://localhost:3000' },
proxy: { '/api': apiTarget },
},
});
+1 -1
View File
@@ -14,7 +14,7 @@ export default defineConfig({
server: {
port: 5175,
proxy: {
'/api': process.env.VITE_API_TARGET ?? 'http://localhost:3000',
'/api': process.env.VITE_API_TARGET ?? 'http://localhost:3010',
},
},
});
+1 -1
View File
@@ -13,6 +13,6 @@ export default defineConfig({
},
server: {
port: 5174,
proxy: { '/api': 'http://localhost:3000' },
proxy: { '/api': process.env.VITE_API_TARGET ?? 'http://localhost:3010' },
},
});
+1 -1
View File
@@ -13,7 +13,7 @@ export default defineConfig({
},
server: {
proxy: {
'/api': 'http://localhost:3000',
'/api': process.env.VITE_API_TARGET ?? 'http://localhost:3010',
},
},
});
+2 -2
View File
@@ -16,7 +16,7 @@ export default defineConfig(async () => ({
plugins: ['@tarojs/plugin-html'],
defineConstants: {
/** H5 静态托管无 /api 代理时直连后端;dev 构建可通过 VITE_API_TARGET 覆盖 */
TARO_APP_API_ORIGIN: JSON.stringify(process.env.VITE_API_TARGET ?? 'http://localhost:3000'),
TARO_APP_API_ORIGIN: JSON.stringify(process.env.VITE_API_TARGET ?? 'http://localhost:3010'),
},
copy: {
patterns: [],
@@ -44,7 +44,7 @@ export default defineConfig(async () => ({
host: '0.0.0.0',
proxy: {
'/api': {
target: process.env.VITE_API_TARGET ?? 'http://localhost:3000',
target: process.env.VITE_API_TARGET ?? 'http://localhost:3010',
changeOrigin: true,
},
},
+1 -1
View File
@@ -5,7 +5,7 @@ function resolveApiBase(): string {
typeof TARO_APP_API_ORIGIN !== 'undefined' && TARO_APP_API_ORIGIN
? TARO_APP_API_ORIGIN
: process.env.TARO_ENV === 'h5'
? 'http://localhost:3000'
? 'http://localhost:3010'
: '';
if (origin) {
return `${origin.replace(/\/$/, '')}/api/v1`;
+2 -2
View File
@@ -21,7 +21,7 @@ pnpm build:mini-user:weapp
| 环节 | 文件 | 说明 |
|------|------|------|
| **编译注入** | `config/index.ts``defineConstants.TARO_APP_API_ORIGIN` | `dev:weapp` / watch → `localhost:3000``build:weapp``--mode production`)→ `https://api.dukanghaoke.com`;可用 `VITE_API_TARGET` 覆盖 |
| **编译注入** | `config/index.ts``defineConstants.TARO_APP_API_ORIGIN` | `dev:weapp` / watch → `localhost:3010``build:weapp``--mode production`)→ `https://api.dukanghaoke.com`;可用 `VITE_API_TARGET` 覆盖 |
| **运行时拼装** | `src/lib/api.ts``resolveApiBase()` | `{origin}/api/v1` |
### 微信登录 `invalid code`
@@ -33,7 +33,7 @@ pnpm build:mini-user:weapp
| 小程序 appid | `project.config.json``wxda31c8e8e85051e7` |
| 后端须配置 | `WX_MINI_APP_ID` / `WX_MINI_APP_SECRET`(与上表一致) |
**本地联调(不接真实微信)**:保持默认即可(API → `localhost:3000`),并开启 Mock
**本地联调(不接真实微信)**:保持默认即可(API → `localhost:3010`),并开启 Mock
```bash
# 终端 1
+1 -1
View File
@@ -11,7 +11,7 @@ const isDevMode =
/** 小程序/H5 请求的后端 origin(不含 /api);本地默认本机,生产构建默认远程 */
const API_ORIGIN =
process.env.VITE_API_TARGET ??
(isDevMode ? 'http://localhost:3000' : 'https://api.dukanghaoke.com');
(isDevMode ? 'http://localhost:3010' : 'https://api.dukanghaoke.com');
const requireFromApp = createRequire(path.resolve(__dirname, '../package.json'));
+1 -1
View File
@@ -10,7 +10,7 @@ function resolveApiBase(): string {
typeof TARO_APP_API_ORIGIN !== 'undefined' && TARO_APP_API_ORIGIN
? TARO_APP_API_ORIGIN
: process.env.TARO_ENV === 'h5'
? 'http://localhost:3000'
? 'http://localhost:3010'
: '';
if (origin) {
return `${origin.replace(/\/$/, '')}/api/v1`;
+1 -1
View File
@@ -8,7 +8,7 @@ DATABASE_URL="mysql://root:root@localhost:6016/dukang_haoke"
REDIS_URL="redis://localhost:6017"
JWT_SECRET="dukang-prev1-dev-secret-change-in-prod"
JWT_EXPIRES_IN="7d"
PORT=3000
PORT=3010
MOCK_SMS=true
# MOCK_SMS=false 时必填(可与 OSS 共用 RAM)
ALIYUN_SMS_SIGN_NAME=
+1 -1
View File
@@ -86,7 +86,7 @@ async function bootstrap() {
app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true }));
app.useGlobalFilters(new HttpExceptionFilter(app.get(AlertService)));
app.useGlobalInterceptors(new ResponseInterceptor(), app.get(LoggingInterceptor));
const port = process.env.PORT || 3000;
const port = process.env.PORT || 3010;
const cfg = loadAppConfig();
const smsMode = cfg.mockSms ? 'MOCK' : 'ALIYUN';
console.log(`[config] NODE_ENV=${process.env.NODE_ENV} MOCK_SMS=${cfg.mockSms} SMS=${smsMode}`);