jubalm
jubalm
HHono
Created by jubalm on 9/9/2024 in #help
basicAuth context?
Just tried out hono and wanted to add basic auth and wanted to pull data from the Env but the context is any instead of what's set on the Bindings. what am i doing wrong here?
import { Hono } from 'hono'
import { basicAuth } from 'hono/basic-auth'

export type Env = {
PASS: string
}

const app = new Hono<{ Bindings: Env }>()

app.post(
'/test',
basicAuth({
verifyUser: (username, password, c) => {
return (username === 'admin' && password === c.env /* <-- does not autocomplete, Context<any, any>? */)
}
}),
async (c) => {
return c.body('OK')
}
)
import { Hono } from 'hono'
import { basicAuth } from 'hono/basic-auth'

export type Env = {
PASS: string
}

const app = new Hono<{ Bindings: Env }>()

app.post(
'/test',
basicAuth({
verifyUser: (username, password, c) => {
return (username === 'admin' && password === c.env /* <-- does not autocomplete, Context<any, any>? */)
}
}),
async (c) => {
return c.body('OK')
}
)
3 replies