NextAuth provider not working with custom nextjs pageExtensions
See original GitHub issueDescribe the bug
I’m using Relay which generates a __generated__
folder inside my pages
folder, and that’s not allowed by Next(it just accept react components inside the pages
folder). So, I added to next.config.js
the config pageExtensions: ['page.js']
and rename all my pages/
files to the .page.js
extension. Now, he’ll no longer consider files without this extension as a React component.
The problem is: my nextAuth app provider(the one inside _app
file) is printing an error in every single page that I enter, that’s why he’s breaking because this custom extension. The errors are:
GET http://localhost:3000/api/auth/session 404 (Not Found)
[next-auth][error][client_fetch_error] https://next-auth.js.org/errors#client_fetch_error /api/auth/session SyntaxError: Unexpected token < in JSON at position 0
POST http://localhost:3000/api/auth/_log 404 (Not Found)
Steps to reproduce
- Create a next app with nextAuth and add the nexAuth provider in the
_app
file. - Create a
next.config.js
file and add thepageExtensions: ['page.js']
config - Rename all your ´/page´ files to the
.page.js
extension - Now you should get a few errors on your console
The repo I’m having this issue is: https://github.com/joao-pedrozo/reviewanything/tree/master/packages/frontend/src/pages
Expected behavior I think that should automatically identify my next.config.js file and adapt to the provider work as expected.
Screenshots or error logs
GET http://localhost:3000/api/auth/session 404 (Not Found)
[next-auth][error][client_fetch_error] https://next-auth.js.org/errors#client_fetch_error /api/auth/session SyntaxError: Unexpected token < in JSON at position 0
POST http://localhost:3000/api/auth/_log 404 (Not Found)
Additional context Add any other context about the problem here.
Feedback Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
- Found the documentation helpful
- Found documentation but was incomplete
- Could not find relevant documentation
- Found the example project helpful
- Did not find the example project helpful
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Im not evenu using custom page extensions but im still getting this issue, im not able to find whats causing the issue,
I’m getting the exact error. Deleting
.next
and re-running didn’t help. It seems like the nested[...nextuath].page.ts
routes are not considered pages by Next (not necessarily Next Auth’s issue).