Open
Description
Checklist
- The issue can be reproduced in the nextjs-auth0 sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
Using Page Router in Next.js 14, I've implement auth for login/signup. I'm also able to get the access token on the server side/middleware of next.js.
I'm trying to get the access token and make a request to my Go backend without using a Next.js api endpoint as a proxy (which works, but is a lot of boilerplate to make an additional next.js endpoint just to then call my go endpoint).
https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md#getting-an-access-token
I've tried using import { getAccessToken } from "@auth0/nextjs-auth0"
as shown in the docs, but I believe its for App Router only. When using it on page router, i get 'cookies was called outside a request scope'
Reproduction
- Setup next.js 14 page router
- setup auth/login using nextjs-auth
- try to make a call to an external api (ex. Golang backend) without using next.js api router as a proxy, for example in a useEffect or using useSWR
Additional context
No response
nextjs-auth0 version
^3.5.0
Next.js version
^14.2.5 Page Router
Node.js version
18.17.0