import { Context, Next, send } from "@oak/oak"; export function routeStaticFilesFrom(staticPaths: string[]) { return async (context: Context>, next: Next) => { for (const path of staticPaths) { try { await send(context, context.request.url.pathname, { root: path, index: "index.html", }); return; } catch { continue; } } // SPA fallback: serve index.html so client-side routes work on direct navigation await send(context, "/index.html", { root: staticPaths[0] }); await next(); }; }