Skip to content

Instantly share code, notes, and snippets.

@yusukebe
Created April 8, 2024 13:49
Show Gist options
  • Save yusukebe/aa0a1c8cbdc9257447179d139debcae3 to your computer and use it in GitHub Desktop.
Save yusukebe/aa0a1c8cbdc9257447179d139debcae3 to your computer and use it in GitHub Desktop.
// app/routes/_middleware.ts
import { createRoute } from 'honox/factory'
export default createRoute(async (c, next) => {
console.log('middleware at app/routes/_middleware.ts')
await next()
})
// app/server.ts
import { createApp } from 'honox/server'
const app = createApp({
init: (app) => {
// The following will be executed.
app.use(async (c, next) => {
console.log('middleware at app/server.ts')
await next()
})
}
})
// The following is not executed because the middleware is overwritten by the HonoX funcs:
app.use(async (c, next) => {
console.log('not executed')
await next()
})
export default app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment