NextJS + Express (Best Practice?)

Hello everyone,

I’m currently migrating from NextAuth to BetterAuth, but I’m running into some problems – especially when it comes to fetching the session server-side in Next.js.

I’ve documented my current setup and my BetterAuth implementation in Notion for reference.

The main issue:
• On localhost the SSR session fetch works.
• Server-side (deployed) it fails – I get a fetch failed error.

When I tried this about half a year ago with an earlier version, I didn’t get a fetch error, but the session was always null on SSR (while client-side it worked fine).

Now, with the latest BetterAuth version, I consistently get fetch failed on SSR.

Here’s my Notion page with all the relevant info (issue described a little bit down):
https://devlix.notion.site/GGuardian-27b0d00e228680cbb1a4c6ae868aea33

Unfortunately, I still haven’t been able to get it working until today.
devlix on Notion
Current Setup
Was this page helpful?