pintoderian / next-directus-auth-ts

Template for project structure with nextjs 14 - next auth - directus and typescript
31 stars 5 forks source link

Is this project using Next JS' app router approach? #9

Open mrfzd opened 2 months ago

mrfzd commented 2 months ago

Hi,

First, I'd like to thank you and whoever contributed their invaluable time and effort to build this! I cloned and ran it locally and it's working perfectly!

QQ: I was able to clone this locally and run it all fine, but when I copied the code to an existing project, then it broke with the below error code, despite following all the instructions and env variables!

api/auth/callback/credentials not loading Just a little context; this only happens when a user types their username and password and clicks submit, all user journeys before clicking the submit button work perfectly.

So I suspect this could be due to not being a Next JS' app router approach! I'm only saying this because there is no src directory at the root of this project. In contrast, with my existing project, everything is inside a src directory i.e. /src/app/api/auth/[...nexthauth]/route.ts.

The clone version of this project works perfectly but not when trying to incorporate this into an existing project!

Do you why this may be? And if you guys encountered a similar error at the time?

Many thanks

mrfzd commented 2 months ago

Ok so after spending some more time trying to debug this issue, I managed to get it working but, there is a big BUT where it only works without the NEXTAUTH_URL in the .env file! Not sure why that is the case but this is what was causing the issue!

Now I don't know the consequences of NOT having this when the app is in prod!

Do you have any idea as to why this is the case? Thanks

pintoderian commented 1 month ago

Hi, I'm glad you like the project. Regarding the environment variable, only the documentation found in next-auth is followed.