-
Assuming that most APIs require authentication, but only a few APIs do not require authentication. For example, Is there any best practice to solve this problem? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
yusukebe
Jan 17, 2023
Replies: 1 comment
-
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) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
0xtoorich
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about doing this?: