|
|
@@ -7,11 +7,11 @@ import { serve } from '@hono/node-server';
|
|
|
import { Hono } from 'hono';
|
|
|
import { createServer as createNodeServer } from 'node:http';
|
|
|
import process from 'node:process';
|
|
|
+import api from './src/server/api.ts';
|
|
|
|
|
|
// 创建 Hono 应用
|
|
|
const app = new Hono();// API路由
|
|
|
|
|
|
-import api from './src/server/api.ts';
|
|
|
|
|
|
|
|
|
app.route('/', api);
|
|
|
@@ -38,10 +38,10 @@ const parentServer = serve({
|
|
|
});
|
|
|
|
|
|
// Cached production assets
|
|
|
-let templateHtml = '';
|
|
|
-if (isProduction) {
|
|
|
- templateHtml = await fs.readFile('./dist/client/index.html', 'utf-8');
|
|
|
-}
|
|
|
+// let templateHtml = '';
|
|
|
+// if (isProduction) {
|
|
|
+// templateHtml = await fs.readFile('./dist/client/index.html', 'utf-8');
|
|
|
+// }
|
|
|
|
|
|
// 生产环境中间件
|
|
|
let compressionMiddleware;
|
|
|
@@ -96,7 +96,7 @@ app.use(async (c, next) => {
|
|
|
}
|
|
|
|
|
|
// 处理基础路径
|
|
|
- const normalizedUrl = path.replace(baseUrl.pathname, '/') || '/';
|
|
|
+ // const normalizedUrl = path.replace(baseUrl.pathname, '/') || '/';
|
|
|
|
|
|
// 开发环境:使用 Vite 中间件
|
|
|
if (!isProduction && vite) {
|
|
|
@@ -248,7 +248,8 @@ app.use(async (c) => {
|
|
|
render = module.render;
|
|
|
} else {
|
|
|
// 生产环境:使用缓存的模板
|
|
|
- const module = (await import('./dist/server/index.js'))
|
|
|
+ // const module = (await import('./dist/server/index.js'))
|
|
|
+ const module = (await import('/src/server/index.tsx'))
|
|
|
template = module.template;
|
|
|
render = module.render;
|
|
|
}
|