diff --git a/apps/backend/src/middlewares/staticFolder.ts b/apps/backend/src/middlewares/staticFolder.ts new file mode 100644 index 0000000..79840fd --- /dev/null +++ b/apps/backend/src/middlewares/staticFolder.ts @@ -0,0 +1,15 @@ +import { serveStatic } from "@hono/node-server/serve-static"; + +/** + * Serves static files from the specified folder, rewriting the request path. + * + * @param path - The root directory from which to serve static files. + * @returns A middleware that serves static files with the modified request path. + */ +const staticFolder = (path: string) => + serveStatic({ + root: path, + rewriteRequestPath: (path) => path.replace(/.*\//, "./"), + }); + +export default staticFolder;