fix: proxy public pages in admin dev server

This commit is contained in:
dushixiang committed 2026-08-12 20:49:40 +08:00
1 parent 33920265e0
commit ef34036bc0
2 files changed
+13 -2

No files matched your search

+4 -1
View File
@@ -11,7 +11,10 @@ cd web && npm ci && npm run dev # 管理后台,http://localho
cd ../pika-default-theme && npm ci && npm run dev # 默认主题,http://localhost:5173/
```
两者都把 `/api/*` 代理到 `http://localhost:8080`,可以同时启动。
管理后台开发服务器保留 `/admin/*`,并将其他路径代理到 `http://localhost:8080`。因此启动 Pika
后端后,可以通过 `http://localhost:5174/` 访问当前公开主题,通过
`http://localhost:5174/admin/` 访问管理后台。默认主题项目的开发服务器也会把 `/api/*`
代理到 Pika 后端,两者可以同时启动。
## 构建
+9 -1
View File
@@ -17,6 +17,14 @@ export default defineConfig({
},
server: {
port: 5174,
proxy: {'/api/': {target: 'http://localhost:8080/', changeOrigin: true}},
proxy: {
// 管理后台由当前 Vite 服务提供,其余路径交给 Pika 后端,
// 这样访问开发端口的根路径时也能打开活动的公开主题。
'^/(?!admin(?:/|$))': {
target: 'http://localhost:8080',
changeOrigin: true,
ws: true,
},
},
},
});