Next.js Discord

Discord Forum

Unauthorized error when calling an API Route from a Server Component

Unanswered
Picardy Spaniel posted this in #help-forum
Open in Discord
Picardy SpanielOP
I am using next-auth, currently my app/profile/page.tsx has this snippet attached, as well as my app/api/profile/route.ts (imports the getUserProfile.ts)

I have included the bearer token already, but it still fails as unauthorized, any additional setup that I might have missed?

2 Replies

Picardy SpanielOP
Thank you, I already got it working by getting the cookies, and setting it on the header.cookie