Added static serve folder middleware
This commit is contained in:
parent
f038485cb7
commit
77fcf88d81
15
apps/backend/src/middlewares/staticFolder.ts
Normal file
15
apps/backend/src/middlewares/staticFolder.ts
Normal file
|
|
@ -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;
|
||||||
Loading…
Reference in New Issue
Block a user