nomadro/.cursor/skills/local-frontend-online-backend/SKILL.md
Eric abdcafb1eb Ship Work access gate, pads/boards upgrades, and locale hydration fix on .com.
Gate /social/work behind join/login/profile; harden Work UX and LanguageSwitcher SSR; deploy portal, admin, and work API.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-08 00:14:39 +08:00

46 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
name: local-frontend-online-backend
description: >-
Hard gate: local frontend must talk to online .com backends, not localhost
FastAPI by default. Use when configuring WORK_API_URL / COFFEE_API_URL /
NOTIFY_API_URL / API_URL, pnpm dev, or fixing「无法连接 work API」on localhost.
---
# 本地前端直连线上后端(写死)
## 铁律(逐字)
**本地前端直连线上后端。**
`pnpm dev` / `localhost:3000` 的业务 API **默认**打 **`https://nomadro.com`**(美国机线上),**禁止**默认假设本机已起 `dev:work-api` / `8021` / `8023` / `8024`。
## 默认上游
| 本地 Next 路径 | 环境变量 | 默认值(无 env 时) |
|----------------|----------|---------------------|
| `/api/work/v1/*` | `WORK_API_URL` | `https://nomadro.com` |
| `/api/notify/v1/*` | `NOTIFY_API_URL` | `https://nomadro.com` |
| `/api/coffee/v1/*` | `COFFEE_API_URL` | `https://nomadro.com` |
| 其它门户业务 | `API_URL` | `https://nomadro.com` |
| 远程配置(浏览器) | `NEXT_PUBLIC_REMOTE_CONFIG_URL` | `https://nomadro.com/api/config` |
代理拼法:`{ORIGIN}/api/work/v1/...` —— **只写站点根**(`https://nomadro.com`),不要写成带 `/api/work/v1` 的完整前缀以免双拼。
## 反模式(禁止)
- `.env.local` 默认 `WORK_API_URL=http://127.0.0.1:8021`,导致 pads「请先启动 pnpm dev:work-api」
- 代码默认 `127.0.0.1:802x` 却对用户说「本地开前端就能用」
- 为躲线上后端,把本地 offline JSON 当成主路径(offline **仅**线上不可达时兜底)
- 要求用户「再开一个 work-api 终端」才算本地可用
## 唯一例外
用户**本轮明确**说要联调本机后端(例如「起本地 work-api」「WORK_API_URL 指 8021」)时,才允许 `.env.local` 指向 `127.0.0.1:802x`。
## Agent 行为
1. 改 work/notify/coffee 代理或 `.env*` 时先读本 skill。
2. 发现默认仍是 localhost → **立刻改成** `https://nomadro.com`。
3. 本地 pads/boards 连不上 → 先查是否误指 127.0.0.1,再查线上 `https://nomadro.com/api/work/v1/health`。
4. **不要**为修本地连通性去上线前端(见 `no-frontend-deploy-without-ok`)。