How to properly protect/access api route on next-auth 5.0.0-beta.4? #9429
Unanswered
romanslonov
asked this question in
Help
Replies: 2 comments 4 replies
-
Are you using middleware? |
Beta Was this translation helpful? Give feedback.
4 replies
-
I have sold this probleme with this code: import { headers } from "next/headers";
const response = await fetch(`...URL/api/posts`, {
headers: new Headers(headers()),
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
I am using this official example repo and faced an issue when trying to get data from protected api route using server side page.
page.ts
lists route
I always got req.auth as
null
and as a result response is{ message: "Not authenticated" }, { status: 401 }
Beta Was this translation helpful? Give feedback.
All reactions