[GH-ISSUE #797] better-fetc with better auth keeps redirecting me #17070

Closed
opened 2026-04-15 15:01:23 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @firstaxel on GitHub (Dec 7, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/797

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). Original GitHub issue: https://github.com/better-auth/better-auth/issues/797 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
GiteaMirror added the locked label 2026-04-15 15:01:23 -05:00
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.

<!-- gh-comment-id:2524981523 --> @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

<!-- gh-comment-id:2525265321 --> @firstaxel commented on GitHub (Dec 7, 2024): Fixed thanks very much
Author
Owner

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

Closing now

<!-- gh-comment-id:2525265723 --> @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?

<!-- gh-comment-id:2565514988 --> @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#17070