refactor(web): replace devd proxy with Next.js rewrites

- Add rewrites in next.config.ts to proxy /api/* to api-dev.copilothub.ai
- Update docs to reflect new local dev workflow (no devd needed)
- Fix web port number in CLAUDE.md (3001 → 3000)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Naiyuan Qing 2026-02-13 13:25:08 +08:00
parent 6e3ba38df6
commit 31c8b1babc
3 changed files with 11 additions and 8 deletions

View file

@ -15,7 +15,7 @@ super-multica/
│ ├── desktop/ ← Electron + Vite + React (`@multica/desktop`) — primary target
│ ├── gateway/ ← NestJS WebSocket gateway (`@multica/gateway`)
│ ├── server/ ← NestJS REST API server (`@multica/server`)
│ ├── web/ ← Next.js 16 web app (`@multica/web`, port 3001)
│ ├── web/ ← Next.js 16 web app (`@multica/web`, port 3000)
│ └── mobile/ ← React Native mobile app (`@multica/mobile`)
├── packages/

View file

@ -2,6 +2,12 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = {
transpilePackages: ["@multica/ui", "@multica/store", "@multica/hooks", "@multica/sdk"],
rewrites: async () => [
{
source: "/api/:path*",
destination: `${process.env.API_URL || "https://api-dev.copilothub.ai"}/api/:path*`,
},
],
headers: async () => [
{
source: "/sw.js",

View file

@ -23,7 +23,7 @@ Desktop 保存到 ~/.super-multica/auth.json
### Web 端
- 端口:**3000**
- 登录 API`/api/v1/auth/login`(通过 devd 代理到后端)
- 登录 API`/api/v1/auth/login`(通过 Next.js rewrites 代理到后端)
- 登录成功后回调:`http://127.0.0.1:{port}/callback?sid=xxx&user=xxx`
### Desktop 端
@ -61,17 +61,14 @@ Desktop 登录成功后SID 和用户信息存储在本地文件:
## 本地调试
```bash
# 1. 启动代理 (devd)
devd -l /=http://127.0.0.1:3000 /api/=https://api-dev.copilothub.ai/api
# 2. 启动 Web
# 1. 启动 WebNext.js rewrites 自动代理 /api/* 到 api-dev.copilothub.ai
pnpm dev:web
# 3. 启动 Desktop
# 2. 启动 Desktop
pnpm dev:desktop
```
本地调试时,通过 devd 将 `/api/` 请求代理到 `api-dev.copilothub.ai`
本地调试时,Next.js rewrites配置在 `apps/web/next.config.ts`)自动将 `/api/*` 请求代理到 `api-dev.copilothub.ai`
## 参考