feat(api): 添加多路由代理处理实现
- 新增api目录下多个接口路径代理处理文件,支持动态拼接目标URL - 根据环境变量选择不同的后端服务地址(如dev和生产环境) - 统一添加TenantId和Authorization请求头传递租户及身份信息 - 实现请求参数及搜索参数的完整转发 - 引入better-sqlite3及node内建模块支持服务端功能 - 新增专家详情页面,实现文章、成果及预约咨询功能展示 - 页面实现加载骨架屏、标签页切换及空状态提示优化体验
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { d as defineEventHandler, e as getQuery, u as useRuntimeConfig, c as getHeader, $ as $fetch, f as createError } from '../../../../nitro/nitro.mjs';
|
||||
import 'node:http';
|
||||
import 'node:https';
|
||||
import 'node:events';
|
||||
import 'node:buffer';
|
||||
import 'node:fs';
|
||||
import 'node:path';
|
||||
import 'node:crypto';
|
||||
import 'node:url';
|
||||
import 'better-sqlite3';
|
||||
|
||||
const getSiteInfo_get = defineEventHandler(async (event) => {
|
||||
var _a;
|
||||
const config = useRuntimeConfig();
|
||||
const query = getQuery(event);
|
||||
const modulesApiBase = config.public.modulesApiBase || config.public.ApiBase || "https://websopy-api.websoft.top/api";
|
||||
const tenantId = getHeader(event, "tenantid") || config.public.tenantId || config.public.TenantId || "5";
|
||||
const authorization = getHeader(event, "authorization");
|
||||
try {
|
||||
return await $fetch("/cms/cms-website/getSiteInfo", {
|
||||
baseURL: modulesApiBase,
|
||||
headers: {
|
||||
TenantId: String(tenantId),
|
||||
...authorization ? { Authorization: String(authorization) } : {}
|
||||
},
|
||||
query
|
||||
});
|
||||
} catch (error) {
|
||||
throw createError({
|
||||
statusCode: (error == null ? void 0 : error.statusCode) || ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.status) || 502,
|
||||
statusMessage: (error == null ? void 0 : error.statusMessage) || "Failed to fetch site info"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export { getSiteInfo_get as default };
|
||||
//# sourceMappingURL=getSiteInfo.get.mjs.map
|
||||
Reference in New Issue
Block a user