@checkstack/backend 0.6.3 → 0.6.5
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/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/src/index.ts +12 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @checkstack/backend
|
|
2
2
|
|
|
3
|
+
## 0.6.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 35a91e5: Fix truncated static file responses in production container
|
|
8
|
+
|
|
9
|
+
Hono's `c.body()` wasn't fully consuming Bun's `ReadableStream` from `file.stream()`, causing truncated responses (e.g. 129B instead of 1098B for the favicon). Switched to reading the file as `ArrayBuffer` before passing to `c.body()`, ensuring the full content is delivered.
|
|
10
|
+
|
|
11
|
+
## 0.6.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- a713e0f: Fix static file Content-Length header stripped by Hono middleware
|
|
16
|
+
|
|
17
|
+
Hono's CORS middleware wraps raw `Response` objects and strips Bun's auto-generated headers. Switched to using `c.body()` + `c.header()` so Content-Type and Content-Length survive the middleware pipeline. Extracted a shared `serveFile` helper for all static file routes.
|
|
18
|
+
|
|
3
19
|
## 0.6.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Server } from "bun";
|
|
2
|
-
import { Hono } from "hono";
|
|
2
|
+
import { type Context, Hono } from "hono";
|
|
3
3
|
import { PluginManager } from "./plugin-manager";
|
|
4
4
|
import { logger } from "hono/logger";
|
|
5
5
|
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
|
@@ -174,6 +174,13 @@ app.get("/.well-known/jwks.json", async (c) => {
|
|
|
174
174
|
const frontendDistPath = process.env.CHECKSTACK_FRONTEND_DIST;
|
|
175
175
|
if (frontendDistPath && fs.existsSync(frontendDistPath)) {
|
|
176
176
|
rootLogger.info(`📦 Serving frontend from: ${frontendDistPath}`);
|
|
177
|
+
/** Serve a static file via Hono's context to preserve headers through middleware. */
|
|
178
|
+
const serveFile = async (c: Context, filePath: string) => {
|
|
179
|
+
const file = Bun.file(filePath);
|
|
180
|
+
const content = await file.arrayBuffer();
|
|
181
|
+
c.header("Content-Type", file.type);
|
|
182
|
+
return c.body(content);
|
|
183
|
+
};
|
|
177
184
|
|
|
178
185
|
// Serve static assets (JS, CSS, images, etc.)
|
|
179
186
|
app.get("/assets/*", async (c) => {
|
|
@@ -181,10 +188,7 @@ if (frontendDistPath && fs.existsSync(frontendDistPath)) {
|
|
|
181
188
|
const filePath = path.join(frontendDistPath, "assets", assetPath);
|
|
182
189
|
|
|
183
190
|
if (fs.existsSync(filePath)) {
|
|
184
|
-
|
|
185
|
-
return new Response(file, {
|
|
186
|
-
headers: { "Content-Type": file.type },
|
|
187
|
-
});
|
|
191
|
+
return serveFile(c, filePath);
|
|
188
192
|
}
|
|
189
193
|
return c.notFound();
|
|
190
194
|
});
|
|
@@ -195,10 +199,7 @@ if (frontendDistPath && fs.existsSync(frontendDistPath)) {
|
|
|
195
199
|
const filePath = path.join(frontendDistPath, "vendor", vendorPath);
|
|
196
200
|
|
|
197
201
|
if (fs.existsSync(filePath)) {
|
|
198
|
-
|
|
199
|
-
return new Response(file, {
|
|
200
|
-
headers: { "Content-Type": file.type },
|
|
201
|
-
});
|
|
202
|
+
return serveFile(c, filePath);
|
|
202
203
|
}
|
|
203
204
|
return c.notFound();
|
|
204
205
|
});
|
|
@@ -218,20 +219,14 @@ if (frontendDistPath && fs.existsSync(frontendDistPath)) {
|
|
|
218
219
|
const staticFilePath = path.join(frontendDistPath, reqPath);
|
|
219
220
|
// Only serve if it's a file (not a directory) and exists
|
|
220
221
|
if (fs.existsSync(staticFilePath) && fs.statSync(staticFilePath).isFile()) {
|
|
221
|
-
|
|
222
|
-
return new Response(file, {
|
|
223
|
-
headers: { "Content-Type": file.type },
|
|
224
|
-
});
|
|
222
|
+
return serveFile(c, staticFilePath);
|
|
225
223
|
}
|
|
226
224
|
}
|
|
227
225
|
|
|
228
226
|
// SPA fallback: serve index.html for all remaining non-API routes
|
|
229
227
|
const indexPath = path.join(frontendDistPath, "index.html");
|
|
230
228
|
if (fs.existsSync(indexPath)) {
|
|
231
|
-
|
|
232
|
-
return new Response(file, {
|
|
233
|
-
headers: { "Content-Type": "text/html" },
|
|
234
|
-
});
|
|
229
|
+
return serveFile(c, indexPath);
|
|
235
230
|
}
|
|
236
231
|
return c.notFound();
|
|
237
232
|
});
|