wildpig 1.5.7 → 1.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/prodServer.ts +7 -5
package/package.json
CHANGED
package/scripts/prodServer.ts
CHANGED
|
@@ -51,12 +51,14 @@ export const startServer = async () => {
|
|
|
51
51
|
const filepath = "./client" + url.pathname;
|
|
52
52
|
// 检查文件是否存在
|
|
53
53
|
if(fs.existsSync(filepath) && fs.statSync(filepath).isFile()){
|
|
54
|
-
return new Response(Bun.file(filepath)
|
|
54
|
+
return new Response(Bun.file(filepath), {
|
|
55
|
+
headers: {
|
|
56
|
+
"Cache-Control": "public, max-age=864000" // 10 天缓存
|
|
57
|
+
}
|
|
58
|
+
});
|
|
55
59
|
}
|
|
56
60
|
// 文件不存在
|
|
57
|
-
return new Response("Not Found", {status: 404
|
|
58
|
-
"Cache-Control": "public, max-age=864000" // 10 天缓存
|
|
59
|
-
}});
|
|
61
|
+
return new Response("Not Found", {status: 404});
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
// 请求服务端数据
|
|
@@ -93,7 +95,7 @@ export const startServer = async () => {
|
|
|
93
95
|
// 2. 获取渲染函数
|
|
94
96
|
const { render } = await import("../entry/server"!);
|
|
95
97
|
// 3. 获取应用程序 HTML
|
|
96
|
-
const appHtml = await render(request)
|
|
98
|
+
const appHtml = await render(request, serverData);
|
|
97
99
|
|
|
98
100
|
// 4. 注入渲染后的应用程序 HTML 到模板中。
|
|
99
101
|
const html = template
|