Using the auth object on server side Nextjs
Hey BetterAuth community 👋 — I’ve got a quick question (and possibly a suggestion) regarding how to properly use the SDK on the backend.
I'm trying to update an organization from a Next.js API route, specifically from a webhook handler for Polar (a payment provider). I noticed there’s a auth.api.updateOrganization method available on the server-side auth object, but its usage is a bit unclear in a backend-only context.
It seems to require headers like 'Content-Type': 'application/json', but since I'm not making an external API call (just referencing the SDK on the server), it feels a bit awkward. Here's what I currently have:
Is this the recommended way to do it on the backend? Or is there a cleaner / more idiomatic approach for server-to-server usage in Next.js (e.g. via service account or internal SDK calls)?
Appreciate any guidance — and happy to file a DX feedback issue if this is an area worth smoothing out.
Thanks!
0 Replies