Skip to content

Commit

Permalink
chore(docs): update middleware redirect example (#10815)
Browse files Browse the repository at this point in the history
Co-authored-by: Nico Domino <yo@ndo.dev>
  • Loading branch information
DenilDenilson and ndom91 committed May 19, 2024
1 parent 83dc8bd commit ece3f6d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/pages/getting-started/session-management/protecting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ You can also use the `auth` method as a wrapper if you'd like to implement more
import { auth } from "@/auth"

export default auth((req) => {
if (!req.auth) {
const url = req.url.replace(req.nextUrl.pathname, "/login")
return Response.redirect(url)
if (!req.auth && req.nextUrl.pathname !== '/login') {
const newUrl = new URL('/login', req.nextUrl.origin)
return Response.redirect(newUrl)
}
})
```
Expand Down

0 comments on commit ece3f6d

Please sign in to comment.