Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middleware Route Protection nextjs example result in Middleware relative urls error #10760

Closed
Ucok23 opened this issue Apr 29, 2024 · 1 comment
Labels
documentation Relates to documentation triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@Ucok23
Copy link

Ucok23 commented Apr 29, 2024

What is the improvement or update you wish to see?

The next-auth docs about protecting route in getting started section resulting middleware relative urls error

import { auth } from "./auth"

export default auth((req) => {
  if (!req.auth) {
    return NextResponse.redirect("/login")
  }
})

Screenshot_20240429_145119_DWService

Is there any context that might help us understand?

NextResponse.redirect(url)
url should be absolute url i think

Does the docs page already exist? Please link to it.

https://authjs.dev/getting-started/session-management/protecting

@Ucok23 Ucok23 added documentation Relates to documentation triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Apr 29, 2024
@balazsorban44
Copy link
Member

Fix in the docs: https://authjs.dev/getting-started/session-management/protecting#nextjs-middleware

In short, you can replace the current URLs pathname.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Relates to documentation triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

2 participants