nextjs-rewrite (#5)

Reviewed-on: #5
Co-authored-by: David Gwilliam <dhgwilliam@gmail.com>
Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
This commit was merged in pull request #5.
This commit is contained in:
2026-03-30 02:30:13 +00:00
committed by david
parent 1a9b3496e1
commit 123df671f5
160 changed files with 19293 additions and 1180 deletions
+20
View File
@@ -0,0 +1,20 @@
import { createAuthClient } from "better-auth/client";
// Get base URL from environment or use localhost as fallback
const getBaseURL = () => {
if (typeof window === 'undefined') {
return process.env.BETTER_AUTH_URL || "http://localhost:3000";
}
// For client-side, use the current origin but allow localhost variations
const origin = window.location.origin;
if (origin.includes('localhost') || origin.includes('127.0.0.1') || origin.includes('0.0.0.0')) {
return "http://localhost:3000"; // Normalize to localhost for Better Auth
}
return origin;
};
export const authClient = createAuthClient({
baseURL: getBaseURL(),
});