ak11
ak11
Explore posts from servers
BABetter Auth
Created by ak11 on 4/29/2025 in #help
Offline support for expo apps
so i'm building an expo app that is to be built on iOS, android as well as to be deployed on the web. i moved away from clerk seeing they've not made enough progress in heir offline support. i need guidance on what to do. i'm tring to build a local first business management tool and one of my requirements is that iw ould want to be able to open my application without necessarily having an internet connection. i thought with the sessions being stored on the user device using expo-securestore i thought that would be a possibility, but it's not. please your help would be very much appreciated
7 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
Hey, i've been having an issue with better auth. i tend to get too many connections error
Invalid `db[getModelName(model)].findFirst()` invocation in
/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/adapters/prisma-adapter/index.cjs:168:52

165 `Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`
166 );
167 }
→ 168 const result = await db[getModelName(model)].findFirst(
Too many database connections opened: FATAL: sorry, too many clients already
2025-04-13T15:29:21.905Z ERROR [Better Auth]: INTERNAL_SERVER_ERROR PrismaClientInitializationError:
Invalid `db[getModelName(model)].findFirst()` invocation in
/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/adapters/prisma-adapter/index.cjs:168:52

165 `Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`
166 );
167 }
→ 168 const result = await db[getModelName(model)].findFirst(
Too many database connections opened: FATAL: sorry, too many clients already

Networking has been disabled
Invalid `db[getModelName(model)].findFirst()` invocation in
/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/adapters/prisma-adapter/index.cjs:168:52

165 `Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`
166 );
167 }
→ 168 const result = await db[getModelName(model)].findFirst(
Too many database connections opened: FATAL: sorry, too many clients already
2025-04-13T15:29:21.905Z ERROR [Better Auth]: INTERNAL_SERVER_ERROR PrismaClientInitializationError:
Invalid `db[getModelName(model)].findFirst()` invocation in
/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/adapters/prisma-adapter/index.cjs:168:52

165 `Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`
166 );
167 }
→ 168 const result = await db[getModelName(model)].findFirst(
Too many database connections opened: FATAL: sorry, too many clients already

Networking has been disabled
and i normally don't get this before Versions are "@better-auth/expo": "^1.2.6-beta.8", and "better-auth": "1.2.6-beta.6", Auth.ts
import { db } from '@/prisma/db';

export const auth = betterAuth({
database: prismaAdapter(db, {
provider: 'postgresql',
}),
import { db } from '@/prisma/db';

export const auth = betterAuth({
database: prismaAdapter(db, {
provider: 'postgresql',
}),
Prisma/db.ts
import { Prisma, PrismaClient } from '@/prisma/generated/prisma';


const db = new PrismaClient({
log:
process.env.EXPO_PUBLIC_ENV === 'development'
? ['query', 'error', 'warn']
: ['error'],
});

export const db;
import { Prisma, PrismaClient } from '@/prisma/generated/prisma';


const db = new PrismaClient({
log:
process.env.EXPO_PUBLIC_ENV === 'development'
? ['query', 'error', 'warn']
: ['error'],
});

export const db;
36 replies
BABetter Auth
Created by ak11 on 4/13/2025 in #bug-reports
Google oauth not redirecting
Everything worked ok before. I had an issue working with google auth on iOS in previous thread. Now I’m back on web and notice when I click my sign in with google button nothing seems to happen. Before it would redirect to
https://accounts.google.com/o/oauth2/auth?response_type=code
https://accounts.google.com/o/oauth2/auth?response_type=code
. Now it does nothing. I tried logging g for errors but no error Relevant code useGoogleSignIn.ts
export const useGoogleSignIn = () => {
const { data: isAuthenticated } = authClient.useSession();
const navContainerRef = useNavigationContainerRef();

useEffect(() => {
if (isAuthenticated) {
if (navContainerRef.isReady()) {
router.push('/recent-businesses');
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAuthenticated, navContainerRef.isReady()]);

return useCallback(async () => {
console.log('callback called');
try {
const { error, data } = await authClient.signIn.social({
provider: 'google',
callbackURL: '/',
});
if (error) {
console.error(error);
}

console.log(data);
} catch (err) {
console.error(err);
}
}, []);
};
export const useGoogleSignIn = () => {
const { data: isAuthenticated } = authClient.useSession();
const navContainerRef = useNavigationContainerRef();

useEffect(() => {
if (isAuthenticated) {
if (navContainerRef.isReady()) {
router.push('/recent-businesses');
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAuthenticated, navContainerRef.isReady()]);

return useCallback(async () => {
console.log('callback called');
try {
const { error, data } = await authClient.signIn.social({
provider: 'google',
callbackURL: '/',
});
if (error) {
console.error(error);
}

console.log(data);
} catch (err) {
console.error(err);
}
}, []);
};
Sign-in.tsx
const googleSignIn = useGoogleSignIn();
const googleSignIn = useGoogleSignIn();
<Pressable
style={[styles.altLoginButton]}
onPress={async () => {
console.log('pressed');
googleSignIn();
}}
>
<Image
source={
Platform.OS !== 'web'
? 'google'
: require('@/assets/images/google.png')
}
style={styles.googleIcon}
/>
<Text style={[styles.altLoginText, Fonts.interRegular]}>
Google
</Text>
</Pressable>
<Pressable
style={[styles.altLoginButton]}
onPress={async () => {
console.log('pressed');
googleSignIn();
}}
>
<Image
source={
Platform.OS !== 'web'
? 'google'
: require('@/assets/images/google.png')
}
style={styles.googleIcon}
/>
<Text style={[styles.altLoginText, Fonts.interRegular]}>
Google
</Text>
</Pressable>
Package version
"better-auth": "1.2.6-beta.6",
"better-auth": "1.2.6-beta.6",
Video of log would be attached
6 replies
BABetter Auth
Created by ak11 on 4/12/2025 in #bug-reports
Invalid Callback URL on expo IOS when doing Google oauth
Hello everyone, I’m trying out Better Auth and I’m running into an issue with my google oauth. Error:
2025-04-12T14:00:21.709Z ERROR [Better Auth]: Invalid callbackURL: business-copilot:///
2025-04-12T14:00:22.223Z INFO [Better Auth]: If it's a valid URL, please add business-copilot:/// to trustedOrigins in your auth config
Current list of trustedOrigins: exp://,http://localhost:8081
ERROR {"code": "INVALID_CALLBACKURL", "message": "Invalid callbackURL", "status": 403, "statusText": ""}
2025-04-12T14:00:21.709Z ERROR [Better Auth]: Invalid callbackURL: business-copilot:///
2025-04-12T14:00:22.223Z INFO [Better Auth]: If it's a valid URL, please add business-copilot:/// to trustedOrigins in your auth config
Current list of trustedOrigins: exp://,http://localhost:8081
ERROR {"code": "INVALID_CALLBACKURL", "message": "Invalid callbackURL", "status": 403, "statusText": ""}
package version:
"@better-auth/expo": "^1.2.6-beta.8",
"better-auth": "1.2.6-beta.6",
"@better-auth/expo": "^1.2.6-beta.8",
"better-auth": "1.2.6-beta.6",
Relevant code: app.json
"scheme": "business-copilot",
"scheme": "business-copilot",
auth.ts
trustedOrigins: ['exp://'],
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
trustedOrigins: ['exp://'],
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
authClient.ts
export const authClient = createAuthClient({
baseURL:
process.env.BETTER_AUTH_URL /* base url of your Better Auth backend. */,
disableDefaultFetchPlugins: true,
plugins: [
expoClient({
scheme: 'business-copilot',
storage: SecureStore,
}),
organizationClient(),
anonymousClient(),
phoneNumberClient(),
],
});
export const authClient = createAuthClient({
baseURL:
process.env.BETTER_AUTH_URL /* base url of your Better Auth backend. */,
disableDefaultFetchPlugins: true,
plugins: [
expoClient({
scheme: 'business-copilot',
storage: SecureStore,
}),
organizationClient(),
anonymousClient(),
phoneNumberClient(),
],
});
Sign-in.tsx
const onGoogleButtonPress = useCallback(async () => {
const { error, data } = await authClient.signIn.social({
provider: 'google',
callbackURL: '/recent-businesses',
});
if (error) {
console.error(error);
}
}, []);
const onGoogleButtonPress = useCallback(async () => {
const { error, data } = await authClient.signIn.social({
provider: 'google',
callbackURL: '/recent-businesses',
});
if (error) {
console.error(error);
}
}, []);
Behaviour: Web: works as expected On iOS (and android I guess): throws error relating to the scheme Please can someone help me out. I would very much appreciate
14 replies
TTCTheo's Typesafe Cult
Created by ak11 on 3/25/2025 in #questions
expo web uploadThing error
hello everyone. was trying out uploadthing for my expo project which i'm building for both native and web. when i use the useDocumentUploader, every works fine on mobile. on web i get an error where i was advised to report it, cause it's hindering me from successfully uploading a file.
UploadThingError: Something went wrong. Please report this to UploadThing.
at Object.INTERNAL_DO_NOT_USE__fatalClientError (entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:338615:54)
at entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:343246:69
at async uploadFunc (entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:466490:9)Caused by: TypeError: Cannot read properties of undefined (reading '_tag')
at entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:343479:31
at async entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:343208:21
at async uploadFunc (entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:466490:9)
UploadThingError: Something went wrong. Please report this to UploadThing.
at Object.INTERNAL_DO_NOT_USE__fatalClientError (entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:338615:54)
at entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:343246:69
at async uploadFunc (entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:466490:9)Caused by: TypeError: Cannot read properties of undefined (reading '_tag')
at entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:343479:31
at async entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:343208:21
at async uploadFunc (entry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.routerRoot=app&resolver.environment=client&transform.environment=client:466490:9)
. Any help on this would be very appreciated
4 replies