middleware icon indicating copy to clipboard operation
middleware copied to clipboard

basicAuth for serveStatic

Open alan-khosro opened this issue 2 years ago • 1 comments

How can I use basicAuth for serveStatic?

import { Hono } from "hono";
import { basicAuth } from "hono/basic-auth";
import { serveStatic } from "hono/bun";

const app = new Hono();

const auth = basicAuth({
    username: "password",
    password: "password",
});

app.use("/*", auth);

app.use("/static/*", auth, serveStatic({ root: "./" }));

Bun.serve({ port: 8000, fetch: app.fetch });

When I hit localhost:8000/static/image.svg it gives error: script "dev" was terminated by signal SIGSEGV (Address boundary error) It works fine with app.HTML_METHODS

alan-khosro avatar Feb 11 '24 21:02 alan-khosro

@alan-khosro

What command did you run? bun run src/index.ts?

yusukebe avatar Feb 15 '24 22:02 yusukebe