mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
* merge `main`, fix workspace dependencies * chore(dev): use `matcher` in Middleware * fix(middleware): support `cookies` as `Map` * simplify * chore(example): use new Middleware API * chore(example): use `next-auth@latest` * docs(middleware): document new Middleware API * docs(ts): update inline example * fix(ts): make cookies optional * remove non-null assertion
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
export { default } from "next-auth/middleware"
|
|
|
|
export const config = { matcher: ["/middleware-protected"] }
|
|
|
|
// Other ways to use this middleware
|
|
|
|
// import withAuth from "next-auth/middleware"
|
|
// import { withAuth } from "next-auth/middleware"
|
|
|
|
// export function middleware(req, ev) {
|
|
// return withAuth(req)
|
|
// }
|
|
|
|
// export function middleware(req, ev) {
|
|
// return withAuth(req, ev)
|
|
// }
|
|
|
|
// export function middleware(req, ev) {
|
|
// return withAuth(req, {
|
|
// callbacks: {
|
|
// authorized: ({ token }) => !!token,
|
|
// },
|
|
// })
|
|
// }
|
|
|
|
// export default withAuth(function middleware(req, ev) {
|
|
// console.log(req.nextauth.token)
|
|
// })
|
|
|
|
// export default withAuth(
|
|
// function middleware(req, ev) {
|
|
// console.log(req, ev)
|
|
// return undefined // NOTE: `NextMiddleware` should allow returning `void`
|
|
// },
|
|
// {
|
|
// callbacks: {
|
|
// authorized: ({ token }) => token.name === "Balázs Orbán",
|
|
// }
|
|
// }
|
|
// )
|
|
|
|
// export default withAuth({
|
|
// callbacks: {
|
|
// authorized: ({ token }) => !!token,
|
|
// },
|
|
// })
|