Monorepo for Wisp.place. A static site hosting service built on top of the AT Protocol.

add debugging

Changed files
+26
hosting-service
+13
hosting-service/src/lib/utils.ts
···
// Allow up to 100MB per file blob, with 2 minute timeout
let content = await safeFetchBlob(blobUrl, { maxSize: 100 * 1024 * 1024, timeout: 120000 });
+
console.log(`[DEBUG] ${filePath}: fetched ${content.length} bytes, base64=${base64}, encoding=${encoding}, mimeType=${mimeType}`);
+
// If content is base64-encoded, decode it back to binary (gzipped or not)
if (base64) {
+
const originalSize = content.length;
// The content from the blob is base64 text, decode it directly to binary
const buffer = Buffer.from(content);
const base64String = buffer.toString('ascii'); // Use ascii for base64 text, not utf-8
+
console.log(`[DEBUG] ${filePath}: base64 string first 100 chars: ${base64String.substring(0, 100)}`);
content = Buffer.from(base64String, 'base64');
+
console.log(`[DEBUG] ${filePath}: decoded from ${originalSize} bytes to ${content.length} bytes`);
+
+
// Check if it's actually gzipped by looking at magic bytes
+
if (content.length >= 2) {
+
const magic = content[0] === 0x1f && content[1] === 0x8b;
+
const byte0 = content[0];
+
const byte1 = content[1];
+
console.log(`[DEBUG] ${filePath}: has gzip magic bytes: ${magic} (0x${byte0?.toString(16)}, 0x${byte1?.toString(16)})`);
+
}
}
const cacheFile = `${CACHE_DIR}/${did}/${site}${dirSuffix}/${filePath}`;
+13
hosting-service/src/server.ts
···
const content = readFileSync(cachedFile);
const metaFile = `${cachedFile}.meta`;
+
console.log(`[DEBUG SERVE] ${requestPath}: file size=${content.length} bytes, metaFile exists=${existsSync(metaFile)}`);
+
// Check if file has compression metadata
if (existsSync(metaFile)) {
const meta = JSON.parse(readFileSync(metaFile, 'utf-8'));
+
console.log(`[DEBUG SERVE] ${requestPath}: meta=${JSON.stringify(meta)}`);
+
+
// Check actual content for gzip magic bytes
+
if (content.length >= 2) {
+
const hasGzipMagic = content[0] === 0x1f && content[1] === 0x8b;
+
const byte0 = content[0];
+
const byte1 = content[1];
+
console.log(`[DEBUG SERVE] ${requestPath}: has gzip magic bytes=${hasGzipMagic} (0x${byte0?.toString(16)}, 0x${byte1?.toString(16)})`);
+
}
+
if (meta.encoding === 'gzip' && meta.mimeType) {
// Serve gzipped content with proper headers
+
console.log(`[DEBUG SERVE] ${requestPath}: serving as gzipped with Content-Encoding header`);
return new Response(content, {
headers: {
'Content-Type': meta.mimeType,