Next.js Discord

Discord Forum

Next-Auth, session and Next Link weird behaviour

Unanswered
White-winged Scoter posted this in #help-forum
Open in Discord
White-winged ScoterOP
I've got an app looking something like this:

- path
| - [slug]
| - - layout.tsx (1)
| - - page.tsx
| - - some more subpages and layouts
| - settings
| - - page.tsx
| - layout.tsx (2)

To be able to visit anything after /path, you need to have a user session
To visit everything behind /slug, you need a user with permission for that slug

In layout (2) there is a check if there is a user session
In layout (1) there is a check if there is a "path user"

Everything works fine when browsing /slug and beyond, but when clicking a Next Link that goes up a level (and only checks for session), the session suddenly is missing.

If I manually go to those pages, it works as intended (unless I click a link that is on the path level (slug level works fine).

I'm very confused on what the issue could be.

Locally, everything works fine. The build also works fine. It only occurs deployed to vercel, but I can't find anything in the logs.

0 Replies