diff --git a/.env.example b/.env.example index 53ed7de..1ceaa66 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,6 @@ # Static assets/page directory SERVE_STATIC= + +# Authentication +AUTH_USERNAME= +AUTH_PASSWORD= diff --git a/routers/cebol.tsx b/routers/cebol.tsx index d922cca..d092dde 100644 --- a/routers/cebol.tsx +++ b/routers/cebol.tsx @@ -1,4 +1,5 @@ import { Hono } from "hono"; +import { basicAuth } from "hono/basic-auth"; import HomePage from "../views/pages/home"; import LinksSection from "../views/sections/links"; import db from "../lib/database"; @@ -7,6 +8,13 @@ import type { Link } from "../types/link"; const router = new Hono(); +router.use( + basicAuth({ + username: process.env.AUTH_USERNAME || "cebol", + password: process.env.AUTH_PASSWORD || "cebol", + }) +); + router.get("/", (c) => { const links = db .query("SELECT * FROM links ORDER BY id DESC")