@payez/next-mvp 4.0.22 → 4.0.24

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.
@@ -49,17 +49,20 @@ function buildBetterAuthProviders(config) {
49
49
  function createBetterAuthInstance(idpConfig) {
50
50
  const appSlug = idpConfig.clientSlug || (0, app_slug_1.getAppSlug)();
51
51
  // Resolve base URL: BETTER_AUTH_URL env > IDP config > localhost fallback
52
- const baseURL = process.env.BETTER_AUTH_URL
52
+ // Must include /api/auth since that's where the catch-all route is mounted
53
+ const rawBaseURL = process.env.BETTER_AUTH_URL
53
54
  || idpConfig.baseClientUrl
54
55
  || `http://localhost:${process.env.PORT || '3000'}`;
56
+ const baseURL = rawBaseURL.replace(/\/+$/, '') + '/api/auth';
55
57
  return (0, better_auth_1.betterAuth)({
56
58
  baseURL,
57
59
  secret: idpConfig.nextAuthSecret,
58
60
  socialProviders: buildBetterAuthProviders(idpConfig),
59
61
  // Trust the app's own origin + any configured base URL
60
62
  trustedOrigins: [
63
+ rawBaseURL,
61
64
  baseURL,
62
- ...(idpConfig.baseClientUrl && idpConfig.baseClientUrl !== baseURL ? [idpConfig.baseClientUrl] : []),
65
+ ...(idpConfig.baseClientUrl ? [idpConfig.baseClientUrl] : []),
63
66
  'http://localhost:3000',
64
67
  'http://localhost:3400',
65
68
  'http://localhost:3600',
@@ -956,14 +956,6 @@ export declare const useSession: () => {
956
956
  code?: string | undefined;
957
957
  message?: string | undefined;
958
958
  }, FetchOptions["throw"] extends true ? true : false>>;
959
- /**
960
- * Sign in with a specific OAuth provider via direct redirect.
961
- *
962
- * better-auth exposes per-provider endpoints at /api/auth/sign-in/{provider}
963
- * (e.g. /api/auth/sign-in/google). The generic signIn.social() method POSTs
964
- * to /api/auth/sign-in/social which doesn't exist — use this instead.
965
- */
966
- export declare function signInWithProvider(provider: string, callbackURL?: string): void;
967
959
  /**
968
960
  * NextAuth-compatible useSession wrapper.
969
961
  *
@@ -10,7 +10,6 @@
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.signOut = exports.signIn = exports.useSession = exports.authClient = void 0;
13
- exports.signInWithProvider = signInWithProvider;
14
13
  exports.useSessionCompat = useSessionCompat;
15
14
  exports.signOutCompat = signOutCompat;
16
15
  const react_1 = require("better-auth/react");
@@ -20,20 +19,6 @@ exports.authClient = (0, react_1.createAuthClient)({
20
19
  });
21
20
  // Convenience exports
22
21
  exports.useSession = exports.authClient.useSession, exports.signIn = exports.authClient.signIn, exports.signOut = exports.authClient.signOut;
23
- /**
24
- * Sign in with a specific OAuth provider via direct redirect.
25
- *
26
- * better-auth exposes per-provider endpoints at /api/auth/sign-in/{provider}
27
- * (e.g. /api/auth/sign-in/google). The generic signIn.social() method POSTs
28
- * to /api/auth/sign-in/social which doesn't exist — use this instead.
29
- */
30
- function signInWithProvider(provider, callbackURL) {
31
- const params = new URLSearchParams();
32
- if (callbackURL)
33
- params.set('callbackURL', callbackURL);
34
- const qs = params.toString();
35
- window.location.href = `/api/auth/sign-in/${provider}${qs ? '?' + qs : ''}`;
36
- }
37
22
  /**
38
23
  * NextAuth-compatible useSession wrapper.
39
24
  *
@@ -44,7 +44,7 @@ function MobileNavDrawer({ isOpen, onClose, navItems, customSections, basePath =
44
44
  onSignIn();
45
45
  }
46
46
  else {
47
- (0, better_auth_client_1.signInWithProvider)('google', signInCallbackUrl);
47
+ better_auth_client_1.authClient.signIn.social({ provider: 'google', callbackURL: signInCallbackUrl });
48
48
  }
49
49
  };
50
50
  const handleSectionItemClick = (item) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payez/next-mvp",
3
- "version": "4.0.22",
3
+ "version": "4.0.24",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -58,9 +58,11 @@ export function createBetterAuthInstance(idpConfig: IDPClientConfig) {
58
58
  const appSlug = idpConfig.clientSlug || getAppSlug();
59
59
 
60
60
  // Resolve base URL: BETTER_AUTH_URL env > IDP config > localhost fallback
61
- const baseURL = process.env.BETTER_AUTH_URL
61
+ // Must include /api/auth since that's where the catch-all route is mounted
62
+ const rawBaseURL = process.env.BETTER_AUTH_URL
62
63
  || idpConfig.baseClientUrl
63
64
  || `http://localhost:${process.env.PORT || '3000'}`;
65
+ const baseURL = rawBaseURL.replace(/\/+$/, '') + '/api/auth';
64
66
 
65
67
  return betterAuth({
66
68
  baseURL,
@@ -70,8 +72,9 @@ export function createBetterAuthInstance(idpConfig: IDPClientConfig) {
70
72
 
71
73
  // Trust the app's own origin + any configured base URL
72
74
  trustedOrigins: [
75
+ rawBaseURL,
73
76
  baseURL,
74
- ...(idpConfig.baseClientUrl && idpConfig.baseClientUrl !== baseURL ? [idpConfig.baseClientUrl] : []),
77
+ ...(idpConfig.baseClientUrl ? [idpConfig.baseClientUrl] : []),
75
78
  'http://localhost:3000',
76
79
  'http://localhost:3400',
77
80
  'http://localhost:3600',
@@ -18,19 +18,6 @@ export const authClient = createAuthClient({
18
18
  // Convenience exports
19
19
  export const { useSession, signIn, signOut } = authClient;
20
20
 
21
- /**
22
- * Sign in with a specific OAuth provider via direct redirect.
23
- *
24
- * better-auth exposes per-provider endpoints at /api/auth/sign-in/{provider}
25
- * (e.g. /api/auth/sign-in/google). The generic signIn.social() method POSTs
26
- * to /api/auth/sign-in/social which doesn't exist — use this instead.
27
- */
28
- export function signInWithProvider(provider: string, callbackURL?: string) {
29
- const params = new URLSearchParams();
30
- if (callbackURL) params.set('callbackURL', callbackURL);
31
- const qs = params.toString();
32
- window.location.href = `/api/auth/sign-in/${provider}${qs ? '?' + qs : ''}`;
33
- }
34
21
 
35
22
  /**
36
23
  * NextAuth-compatible useSession wrapper.
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { useEffect, useCallback } from 'react';
4
- import { authClient, signInWithProvider } from '../../client/better-auth-client';
4
+ import { authClient } from '../../client/better-auth-client';
5
5
  import { usePathname } from 'next/navigation';
6
6
  import Image from 'next/image';
7
7
  import Link from 'next/link';
@@ -90,7 +90,7 @@ export function MobileNavDrawer({
90
90
  if (onSignIn) {
91
91
  onSignIn();
92
92
  } else {
93
- signInWithProvider('google', signInCallbackUrl);
93
+ authClient.signIn.social({ provider: 'google', callbackURL: signInCallbackUrl });
94
94
  }
95
95
  };
96
96