better-fetc with better auth keeps redirecting me #356

Closed
opened 2026-03-13 07:43:02 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @firstaxel on GitHub (Dec 7, 2024).

i am working on a monorepo with better auth but upon using the better-fetch to fetch the session in the middleware i am getting redirected countless times that the page wont load please check it out using the same middleware config as the better-auth nextjs demo

P.S it doesnt fetch the session i think that is why there a lot of redirection
Also API for my app is a microservice meaning i splitted it into a different nextjs app with it use only for my api but everything is configured correctly cause i was able to use to use authClient and auth api severside with the auth.api but i can get session cookies in the middleware with better-fetch

Originally created by @firstaxel on GitHub (Dec 7, 2024). i am working on a monorepo with better auth but upon using the better-fetch to fetch the session in the middleware i am getting redirected countless times that the page wont load please check it out using the same middleware config as the better-auth nextjs demo P.S it doesnt fetch the session i think that is why there a lot of redirection Also API for my app is a microservice meaning i splitted it into a different nextjs app with it use only for my api but everything is configured correctly cause i was able to use to use authClient and auth api severside with the auth.api but i can get session cookies in the middleware with better-fetch
Author
Owner

@Bekacru commented on GitHub (Dec 7, 2024):

Check if the session is being fetched properly, and review your redirection logic in case it might be causing an infinite redirection loop.

@Bekacru commented on GitHub (Dec 7, 2024): Check if the session is being fetched properly, and review your redirection logic in case it might be causing an infinite redirection loop.
Author
Owner

@firstaxel commented on GitHub (Dec 7, 2024):

Fixed thanks very much

@firstaxel commented on GitHub (Dec 7, 2024): Fixed thanks very much
Author
Owner

@firstaxel commented on GitHub (Dec 7, 2024):

Closing now

@firstaxel commented on GitHub (Dec 7, 2024): Closing now
Author
Owner

@jessaleks commented on GitHub (Dec 30, 2024):

@firstaxel what did you do to fix the issue?

@jessaleks commented on GitHub (Dec 30, 2024): @firstaxel what did you do to fix the issue?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#356