mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 00:45:29 +08:00
fix(vercel): route admin static assets before api fallback
This commit is contained in:
@@ -66,6 +66,7 @@ Notes:
|
||||
- Serverless entry: `api/index.go`
|
||||
- Rewrites and cache headers: `vercel.json`
|
||||
- Build stage runs `npm ci --prefix webui && npm run build --prefix webui` automatically
|
||||
- `vercel.json` routes `/admin/assets/*` and the `/admin` page to static output, while `/admin/*` APIs still go to `api/index`
|
||||
|
||||
Minimum environment variables:
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ docker-compose up -d --build
|
||||
- serverless 入口:`api/index.go`
|
||||
- 路由与缓存头:`vercel.json`
|
||||
- 构建阶段会自动执行 `npm ci --prefix webui && npm run build --prefix webui`
|
||||
- `vercel.json` 已将 `/admin/assets/*` 与 `/admin` 页面走静态产物,`/admin/*` API 仍走 `api/index`
|
||||
|
||||
至少配置环境变量:
|
||||
|
||||
|
||||
57
vercel.json
57
vercel.json
@@ -2,12 +2,59 @@
|
||||
"version": 2,
|
||||
"buildCommand": "npm ci --prefix webui && npm run build --prefix webui",
|
||||
"outputDirectory": "static/admin",
|
||||
"functions": {
|
||||
"api/index.go": {
|
||||
"includeFiles": "static/admin/**"
|
||||
}
|
||||
},
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "/admin/login",
|
||||
"destination": "/api/index"
|
||||
},
|
||||
{
|
||||
"source": "/admin/verify",
|
||||
"destination": "/api/index"
|
||||
},
|
||||
{
|
||||
"source": "/admin/config",
|
||||
"destination": "/api/index"
|
||||
},
|
||||
{
|
||||
"source": "/admin/keys(.*)",
|
||||
"destination": "/api/index"
|
||||
},
|
||||
{
|
||||
"source": "/admin/accounts(.*)",
|
||||
"destination": "/api/index"
|
||||
},
|
||||
{
|
||||
"source": "/admin/queue/status",
|
||||
"destination": "/api/index"
|
||||
},
|
||||
{
|
||||
"source": "/admin/import",
|
||||
"destination": "/api/index"
|
||||
},
|
||||
{
|
||||
"source": "/admin/test",
|
||||
"destination": "/api/index"
|
||||
},
|
||||
{
|
||||
"source": "/admin/vercel/(.*)",
|
||||
"destination": "/api/index"
|
||||
},
|
||||
{
|
||||
"source": "/admin/export",
|
||||
"destination": "/api/index"
|
||||
},
|
||||
{
|
||||
"source": "/admin/assets/(.*)",
|
||||
"destination": "/assets/$1"
|
||||
},
|
||||
{
|
||||
"source": "/admin",
|
||||
"destination": "/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/admin/(.*)",
|
||||
"destination": "/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/(.*)",
|
||||
"destination": "/api/index"
|
||||
|
||||
Reference in New Issue
Block a user