From 8b485fe73f5cccddcce6897f54fcbcbca5140fae Mon Sep 17 00:00:00 2001 From: CallMeVerity Date: Thu, 4 Jun 2026 22:47:25 +0100 Subject: [PATCH] Re-add static file serving catch-all route --- backend/src/index.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/src/index.ts b/backend/src/index.ts index 8679d45..2e9a36a 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -3,6 +3,8 @@ import { cors } from "@elysiajs/cors"; import { videoRoutes } from "./routes/videos"; import { initDb } from "./services/db"; import { renderRunPage, getOembed } from "./embeds"; +import { join } from "path"; +import { existsSync, statSync } from "fs"; initDb(); @@ -29,6 +31,19 @@ const app = new Elysia() headers: { "Content-Type": result.contentType }, }); }) + .get("*", ({ request }) => { + const url = new URL(request.url); + const pathname = url.pathname; + + const filePath = join(STATIC_DIR, pathname); + if (existsSync(filePath) && statSync(filePath).isFile()) + return Bun.file(filePath); + + const indexPath = join(STATIC_DIR, "index.html"); + if (existsSync(indexPath)) return Bun.file(indexPath); + + return status(404, "Not found"); + }) .listen(PORT); console.log(`surf.nathan.rip running on port ${PORT}`);