tangled
alpha
login
or
join now
notjack.space
/
wisp.place-monorepo
forked from
nekomimi.pet/wisp.place-monorepo
0
fork
atom
Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol.
0
fork
atom
overview
issues
pulls
pipelines
how could i forget cors
nekomimi.pet
3 months ago
7dd6c40a
d1d0e343
+11
1 changed file
expand all
collapse all
unified
split
hosting-service
src
server.ts
+11
hosting-service/src/server.ts
···
1
import { Hono } from 'hono';
0
2
import { getWispDomain, getCustomDomain, getCustomDomainByHash } from './lib/db';
3
import { resolveDid, getPdsForDid, fetchSiteRecord, downloadAndCacheSite, getCachedFilePath, isCached, sanitizePath, shouldCompressMimeType } from './lib/utils';
4
import { rewriteHtmlPaths, isHtmlContent } from './lib/html-rewriter';
···
537
}
538
539
const app = new Hono();
0
0
0
0
0
0
0
0
0
0
540
541
// Add observability middleware
542
app.use('*', observabilityMiddleware('hosting-service'));
···
1
import { Hono } from 'hono';
2
+
import { cors } from 'hono/cors';
3
import { getWispDomain, getCustomDomain, getCustomDomainByHash } from './lib/db';
4
import { resolveDid, getPdsForDid, fetchSiteRecord, downloadAndCacheSite, getCachedFilePath, isCached, sanitizePath, shouldCompressMimeType } from './lib/utils';
5
import { rewriteHtmlPaths, isHtmlContent } from './lib/html-rewriter';
···
538
}
539
540
const app = new Hono();
541
+
542
+
// Add CORS middleware - allow all origins for static site hosting
543
+
app.use('*', cors({
544
+
origin: '*',
545
+
allowMethods: ['GET', 'HEAD', 'OPTIONS'],
546
+
allowHeaders: ['Content-Type', 'Authorization'],
547
+
exposeHeaders: ['Content-Length', 'Content-Type', 'Content-Encoding', 'Cache-Control'],
548
+
maxAge: 86400, // 24 hours
549
+
credentials: false,
550
+
}));
551
552
// Add observability middleware
553
app.use('*', observabilityMiddleware('hosting-service'));