Middleware SDK

Intercept and process multi-tenant requests at the edge before they hit your application.

Basic Usage

Wrap your Next.js middleware with `withOdyssey` to automatically handle subdomain resolution and domain mapping.

import { withOdyssey } from '@odyssey/nextjs'

export default withOdyssey({
  // Enforce auth on all dashboard routes
  protectedRoutes: ['/dashboard/:path*'],
  
  // Custom logic after tenant resolution
  afterResolution: async (request, tenant) => {
    // Custom edge logic here
  }
})

export const config = {
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
}