Files
Genarrative/src/config/viteProxyConfig.test.ts
T
kdletters 8bd8363ffa 修正原生壳公开主站配置
将原生壳公开主站统一为 www.genarrative.world

调整 Tauri release 直接加载线上主站并移除 frontendDist 打包

补齐创作入口配置开发代理与回归测试

同步原生壳方案文档和共享记忆
2026-06-22 15:07:02 +08:00

61 lines
2.0 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import viteConfig from '../../vite.config';
describe('vite dev api proxy', () => {
it('forwards the profile main route to the Rust API server', async () => {
const resolvedConfig =
typeof viteConfig === 'function'
? await viteConfig({ command: 'serve', mode: 'test' })
: viteConfig;
// 中文注释:`/api/profile/*` 是“我的”和“存档”页面的主链路由;
// 本地 Vite 若漏配代理,会把请求回退到 index.html,前端再按 JSON 解析就会报 `Unexpected token '<'`。
expect(resolvedConfig.server?.proxy).toEqual(
expect.objectContaining({
'/api/profile': expect.objectContaining({
target: expect.any(String),
changeOrigin: true,
secure: false,
}),
}),
);
});
it('forwards the public creation entry config route to the Rust API server', async () => {
const resolvedConfig =
typeof viteConfig === 'function'
? await viteConfig({ command: 'serve', mode: 'test' })
: viteConfig;
// 中文注释:创作入口配置是底部加号入口的首屏事实源,漏配代理会回退 index.html。
expect(resolvedConfig.server?.proxy).toEqual(
expect.objectContaining({
'/api/creation-entry': expect.objectContaining({
target: expect.any(String),
changeOrigin: true,
secure: false,
}),
}),
);
});
it('forwards the admin route to the admin dev server', async () => {
const resolvedConfig =
typeof viteConfig === 'function'
? await viteConfig({ command: 'serve', mode: 'test' })
: viteConfig;
// 中文注释:本地完整栈需要能从主站 `/admin/` 进入后台,贴近生产同域部署形态。
expect(resolvedConfig.server?.proxy).toEqual(
expect.objectContaining({
'/admin/': expect.objectContaining({
target: expect.stringContaining(':3102'),
changeOrigin: true,
secure: false,
}),
}),
);
});
});