@payez/next-mvp 4.0.5 → 4.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,7 @@ export declare function buildBetterAuthProviders(config: IDPClientConfig): Recor
29
29
  * Call after getIDPClientConfig() resolves.
30
30
  */
31
31
  export declare function createBetterAuthInstance(idpConfig: IDPClientConfig): import("better-auth").Auth<{
32
+ baseURL: string;
32
33
  secret: string;
33
34
  socialProviders: Record<string, BetterAuthSocialProvider>;
34
35
  trustedOrigins: string[];
@@ -45,13 +45,18 @@ function buildBetterAuthProviders(config) {
45
45
  */
46
46
  function createBetterAuthInstance(idpConfig) {
47
47
  const appSlug = idpConfig.clientSlug || (0, app_slug_1.getAppSlug)();
48
+ // Resolve base URL: BETTER_AUTH_URL env > IDP config > localhost fallback
49
+ const baseURL = process.env.BETTER_AUTH_URL
50
+ || idpConfig.baseClientUrl
51
+ || `http://localhost:${process.env.PORT || '3000'}`;
48
52
  return (0, better_auth_1.betterAuth)({
53
+ baseURL,
49
54
  secret: idpConfig.nextAuthSecret,
50
55
  socialProviders: buildBetterAuthProviders(idpConfig),
51
56
  // Trust the app's own origin + any configured base URL
52
57
  trustedOrigins: [
53
- ...(idpConfig.baseClientUrl ? [idpConfig.baseClientUrl] : []),
54
- ...(process.env.BETTER_AUTH_URL ? [process.env.BETTER_AUTH_URL] : []),
58
+ baseURL,
59
+ ...(idpConfig.baseClientUrl && idpConfig.baseClientUrl !== baseURL ? [idpConfig.baseClientUrl] : []),
55
60
  'http://localhost:3000',
56
61
  'http://localhost:3400',
57
62
  'http://localhost:3600',
@@ -12,6 +12,7 @@ import 'server-only';
12
12
  * Get the initialized Better Auth instance (singleton).
13
13
  */
14
14
  export declare function getAuthInstance(): Promise<import("better-auth/types").Auth<{
15
+ baseURL: string;
15
16
  secret: string;
16
17
  socialProviders: Record<string, import("../auth/better-auth").BetterAuthSocialProvider>;
17
18
  trustedOrigins: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payez/next-mvp",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -56,15 +56,21 @@ export function buildBetterAuthProviders(
56
56
  export function createBetterAuthInstance(idpConfig: IDPClientConfig) {
57
57
  const appSlug = idpConfig.clientSlug || getAppSlug();
58
58
 
59
+ // Resolve base URL: BETTER_AUTH_URL env > IDP config > localhost fallback
60
+ const baseURL = process.env.BETTER_AUTH_URL
61
+ || idpConfig.baseClientUrl
62
+ || `http://localhost:${process.env.PORT || '3000'}`;
63
+
59
64
  return betterAuth({
65
+ baseURL,
60
66
  secret: idpConfig.nextAuthSecret as string,
61
67
 
62
68
  socialProviders: buildBetterAuthProviders(idpConfig),
63
69
 
64
70
  // Trust the app's own origin + any configured base URL
65
71
  trustedOrigins: [
66
- ...(idpConfig.baseClientUrl ? [idpConfig.baseClientUrl] : []),
67
- ...(process.env.BETTER_AUTH_URL ? [process.env.BETTER_AUTH_URL] : []),
72
+ baseURL,
73
+ ...(idpConfig.baseClientUrl && idpConfig.baseClientUrl !== baseURL ? [idpConfig.baseClientUrl] : []),
68
74
  'http://localhost:3000',
69
75
  'http://localhost:3400',
70
76
  'http://localhost:3600',