Skip to content

How to set authentication whitelist? #809

Answered by yusukebe
0xtoorich asked this question in Q&A
Discussion options

You must be logged in to vote

How about doing this?:

const auth: MiddlewareHandler = async (_c, next) => {
  console.log('auth-middleware')
  await next()
}

const api = new Hono()
api.use('*', auth)
api.get('*', (c) => c.text('should be authorized!'))

const skip = new Hono()
skip.get('/api/*', (c) => c.text('skip!'))

const app = new Hono()

app.route('/', skip)
app.route('/', api)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by 0xtoorich
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants