serve static assets from local public/ instead of static.officer.dev, simplify gmail history 404/410 handling
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+10
-3
@@ -20,6 +20,13 @@ import { toShellUsername } from './servers/data-path';
|
||||
|
||||
const { PORT = '5000' } = process.env;
|
||||
|
||||
// Build static file routes from public/
|
||||
const publicRoutes: Record<string, (req: Request) => Response> = {};
|
||||
for await (const file of new Bun.Glob('**').scan({ cwd: './public' })) {
|
||||
const bunFile = Bun.file(`./public/${file}`);
|
||||
publicRoutes[`/${file}`] = () => new Response(bunFile);
|
||||
}
|
||||
|
||||
type WSData = {
|
||||
userId: number;
|
||||
email: string;
|
||||
@@ -256,14 +263,14 @@ const server = serve({
|
||||
idleTimeout: 60,
|
||||
maxRequestBodySize: 1024 * 1024 * 1024 * 50, // 50 GB
|
||||
routes: {
|
||||
'/og-image.jpg': () => new Response(Bun.file('public/og-image.jpg'), { headers: { 'Content-Type': 'image/jpeg' } }),
|
||||
...publicRoutes,
|
||||
'/novnc/*': (req) => {
|
||||
const file = Bun.file(`public${new URL(req.url).pathname}`);
|
||||
return new Response(file, { headers: { 'Content-Type': 'application/javascript' } });
|
||||
return new Response(file);
|
||||
},
|
||||
'/vendor/*': (req) => {
|
||||
const file = Bun.file(`public${new URL(req.url).pathname}`);
|
||||
return new Response(file, { headers: { 'Content-Type': 'application/javascript' } });
|
||||
return new Response(file);
|
||||
},
|
||||
'/api/dev-server-proxy/*': (req, server) => {
|
||||
if (req.headers.get('upgrade') === 'websocket') return upgradeDevServerWs(req, server);
|
||||
|
||||
Reference in New Issue
Block a user