Ali Khosro
Ali Khosro

Reputation: 1830

In Hono, how to use basicAuth with serveStatic?

When using basicAuth for serveStatic, it throws SIGSEGV error:

error: script "dev" was terminated by signal SIGSEGV (Address boundary error)

It works fine with html methods like app.get

Simple example:

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 });

Upvotes: 0

Views: 391

Answers (1)

Ali Khosro
Ali Khosro

Reputation: 1830

Answering my own question after resolution just for future references:

I tried restarting the computer, did not work. I upgraded the library (bun) and solved the problem, though it was nothing in their release notes about this bug and resolution. So in the future, if you have similar strange problem, try to upgrade/downgrade the referenced library to see if it is caused by an unintended bug in the release you use.

Upvotes: 0

Related Questions