2025-11-24 01:00:50 +01:00
|
|
|
import { createAuthClient } from 'better-auth/svelte';
|
2026-05-20 00:30:25 +01:00
|
|
|
import { getRequestBaseUrl } from '$lib/utils/services/api';
|
2026-03-09 11:18:22 +01:00
|
|
|
import { ssoClient } from '@better-auth/sso/client';
|
2025-11-24 01:00:50 +01:00
|
|
|
|
2026-05-20 00:30:25 +01:00
|
|
|
// Server: PRIVATE_SERVER_URL (Render internal). Browser: same-origin /api
|
|
|
|
|
// through the Cloudflare Worker proxy, so auth cookies stay host-only on
|
|
|
|
|
// whichever domain the user is on (app, tenant subdomain, or BYOD).
|
2025-11-24 01:00:50 +01:00
|
|
|
export const authClient = createAuthClient({
|
2026-05-20 00:30:25 +01:00
|
|
|
baseURL: getRequestBaseUrl(),
|
2025-11-24 01:00:50 +01:00
|
|
|
fetchOptions: {
|
|
|
|
|
credentials: 'include' // Include cookies in requests
|
2026-03-09 11:18:22 +01:00
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
ssoClient({
|
|
|
|
|
domainVerification: {
|
|
|
|
|
enabled: true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
]
|
2025-11-24 01:00:50 +01:00
|
|
|
});
|