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:
parent
6e3ba38df6
commit
31c8b1babc
3 changed files with 11 additions and 8 deletions
|
|
@ -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/
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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. 启动 Web(Next.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`。
|
||||
|
||||
## 参考
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue