The recipes.blue monorepo recipes.blue
recipes appview atproto
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: custom html resolver until honojs/hono#3736 is resolved

+23 -2
+23 -2
apps/api/src/index.ts
··· 8 8 import { ZodError } from "zod"; 9 9 import { CookieStore, Session, sessionMiddleware } from "hono-sessions"; 10 10 import { CookwareSession } from "./util/api.js"; 11 - import { serveStatic } from "@hono/node-server/serve-static"; 12 11 import * as Sentry from "@sentry/node" 12 + import { readFileSync } from "fs"; 13 + import { getFilePathWithoutDefaultDocument } from "hono/utils/filepath"; 13 14 14 15 if (env.SENTRY_DSN) { 15 16 Sentry.init({ ··· 86 87 } 87 88 }); 88 89 89 - app.use('/*', serveStatic({ root: env.PUBLIC_DIR, rewriteRequestPath: () => 'index.html' })); 90 + // TODO: Replace custom impl with this when issue is addressed: 91 + // https://github.com/honojs/hono/issues/3736 92 + // app.use('/*', serveStatic({ root: env.PUBLIC_DIR, rewriteRequestPath: () => 'index.html' })); 93 + 94 + app.use('/*', async (ctx, next) => { 95 + if (ctx.finalized) return next(); 96 + 97 + let path = getFilePathWithoutDefaultDocument({ 98 + filename: 'index.html', 99 + root: env.PUBLIC_DIR, 100 + }) 101 + 102 + if (path) { 103 + path = `./${path}`; 104 + } else { 105 + return next(); 106 + } 107 + 108 + const index = readFileSync(path).toString(); 109 + return ctx.html(index); 110 + }); 90 111 91 112 serve({ 92 113 fetch: app.fetch,