Struggling with utilizing the unstable_getServerSession
in a nextJS API route after switching from a custom authentication method. Wondering if I may have misconfigured JWT or missing something obvious.
Referenced the tutorial "Securing API routes": pages/api/get-session-example.js
https://next-auth.js.org/tutorials/securing-pages-and-api-routes#securing-api-routes
- Utilizing the
getServerSideProps
function to make an Axios call to my next/API endpoint - Sending a
Bearer token
in the header of the next/API call - Expecting the API endpoint to authenticate the user using JWT
- Subsequently fetching Stripe subscriptions based on the
stripe_customer_id
embedded in the JWT
However, the session
and token
within the next/API endpoint always return as null
This is the snippet for my getServerSideProps
function:
// Code block here...
For the next/API endpoint /api/account/subscriptions
:
// Code block here...
Here's the complete [...nextauth].ts
file:
Mentioned that the JWT is created by a Rails backend.
// Code block here...
Seeking assistance in resolving this issue which has been persisting for days without resolution. Cross-posting from GitHub to StackOverflow in hopes of getting insights from the community.