Dev
Dev
Explore posts from servers
BABetter Auth
Created by Dev on 3/1/2025 in #help
Type Error: Type instantiation is excessively deep and possibly infinite
I recently upgraded to the latest version of better-auth and these errors started popping up randomly, before upgrading i wasn't getting such errors I'm using nextjs + hono, earlier i was using nextjs handler and i started getting these errors so i decided to try with the hono handler but it was of no use
./src/lib/auth-client.ts:4:27
▲ Type error: Type instantiation is excessively deep and possibly infinite.

▲ 2 | import { createAuthClient } from "better-auth/react";
▲ 3 |
▲ > 4 | export const authClient = createAuthClient({
▲ | ^
▲ 5 | baseURL: env.NEXT_PUBLIC_BASE_URL!,
▲ 6 | });
▲ 7 |
▲ Next.js build worker exited with code: 1 and signal: null
./src/lib/auth-client.ts:4:27
▲ Type error: Type instantiation is excessively deep and possibly infinite.

▲ 2 | import { createAuthClient } from "better-auth/react";
▲ 3 |
▲ > 4 | export const authClient = createAuthClient({
▲ | ^
▲ 5 | baseURL: env.NEXT_PUBLIC_BASE_URL!,
▲ 6 | });
▲ 7 |
▲ Next.js build worker exited with code: 1 and signal: null
similarly with the following code:
const session = await auth.api.getSession({
^^^^^^^^
headers: c.req.raw.headers,
});
Type instantiation is excessively deep and possibly infinite
const session = await auth.api.getSession({
^^^^^^^^
headers: c.req.raw.headers,
});
Type instantiation is excessively deep and possibly infinite
im using session in all the APIs but this error only pops up on any one of them, if i reload the vscode window, this error will appear on some other api -- "better-auth": "^1.1.21", "hono": "^4.7.2",
2 replies
BABetter Auth
Created by Dev on 2/17/2025 in #help
React Router v7 Integration
I want to add auth in react router v7 app, the better-auth docs only mention the integration for Remix, so i tried using that but it didnt work im new to react router / remix and dont know how to make it work the below method mentioned in remix integration docs gives 405 error on form submission // POST http://localhost:5173/api/auth/sign-up/email 405 (Method Not Allowed)
const signUp = async () => {
await authClient.signUp.email(
{
email,
password,
name,
},
{
onRequest: () => {
console.warn("Sign up Initiated...");
},
onSuccess: () => {
alert("Successfully signed up!");
},
onError: (ctx) => {
alert(ctx.error);
},
}
);
};
const signUp = async () => {
await authClient.signUp.email(
{
email,
password,
name,
},
{
onRequest: () => {
console.warn("Sign up Initiated...");
},
onSuccess: () => {
alert("Successfully signed up!");
},
onError: (ctx) => {
alert(ctx.error);
},
}
);
};
12 replies
CDCloudflare Developers
Created by Dev on 2/9/2025 in #pages-help
Next.js + Cloudflare pages functions
I tried it myself but was a nightmare to work with, is there any guide or github repo i can follow to make it work?
6 replies
DTDrizzle Team
Created by Dev on 2/9/2025 in #help
Cloudflare d1 on cloudflare pages functions
In the drizzle docs, the following code is mentioned to work with cloudflare workers but how do I make it work for cloudflare pages functions
import { drizzle } from 'drizzle-orm/d1';

export interface Env {
DB: D1Database;
}

export default {
async fetch(request: Request, env: Env) {
const db = drizzle(env.DB);
const result = await db.select().from(users).all()
return Response.json(result);
},
};
import { drizzle } from 'drizzle-orm/d1';

export interface Env {
DB: D1Database;
}

export default {
async fetch(request: Request, env: Env) {
const db = drizzle(env.DB);
const result = await db.select().from(users).all()
return Response.json(result);
},
};
I also need to export a singleton db instance from it to pass it to my better-auth instance, how do i make it work?
1 replies
CDCloudflare Developers
Created by Dev on 1/25/2025 in #pages-help
Help: Binding undefined during build process
I'm creating a rag app entirely with cloudflare and next-on-pages and hono as api server however, when i try to access the binding, it gives this error.
[wrangler:inf] GET /chat 200 OK (21ms)
[wrangler:inf] GET /_next/static/chunks/808-024d9e9f46b0d710.js 200 OK (7ms)
✘ [ERROR] Error creating context: TypeError: Cannot destructure property 'AI' of 'e.env' as it is undefined.

✘ [ERROR] Environment not found
[wrangler:inf] POST /api/context/text 500 Internal Server Error (79ms)
[wrangler:inf] GET /chat 200 OK (21ms)
[wrangler:inf] GET /_next/static/chunks/808-024d9e9f46b0d710.js 200 OK (7ms)
✘ [ERROR] Error creating context: TypeError: Cannot destructure property 'AI' of 'e.env' as it is undefined.

✘ [ERROR] Environment not found
[wrangler:inf] POST /api/context/text 500 Internal Server Error (79ms)
heres the code i'm using
const app = new Hono<{ Bindings: CloudflareEnv }>();
//`CloudflareEnv` is generated by running the command cf-typegen

app.post("/", zValidator("json", textContextSchema), async (c) => {
..
const { AI, VECTORIZE } = c.env;
if (c.env) {
// Debugging
console.log("Environment Bindings: ", c.env);
console.log("AI Binding: ", AI);
console.log("VECTORIZE Binding: ", VECTORIZE);

const embeddingResult = await c.env.AI.run(
"@cf/baai/bge-base-en-v1.5",
{
text: content,
},
);

const embedding = embeddingResult.data[0];

// 6. Save the embeddings into Vectorize
if (embedding && embedding.length > 0) {
await c.env.VECTORIZE.insert([
{
id: GenerateUUID(),
values: embedding,
metadata: { text: content, context_id: contextId },
},
]);
} else {
console.error("Invalid embedding:", embedding);
}
} else {
console.error("Environment not found");
return c.json({ error: "Environment bindings inaccessible" }, 500);
}
...
const app = new Hono<{ Bindings: CloudflareEnv }>();
//`CloudflareEnv` is generated by running the command cf-typegen

app.post("/", zValidator("json", textContextSchema), async (c) => {
..
const { AI, VECTORIZE } = c.env;
if (c.env) {
// Debugging
console.log("Environment Bindings: ", c.env);
console.log("AI Binding: ", AI);
console.log("VECTORIZE Binding: ", VECTORIZE);

const embeddingResult = await c.env.AI.run(
"@cf/baai/bge-base-en-v1.5",
{
text: content,
},
);

const embedding = embeddingResult.data[0];

// 6. Save the embeddings into Vectorize
if (embedding && embedding.length > 0) {
await c.env.VECTORIZE.insert([
{
id: GenerateUUID(),
values: embedding,
metadata: { text: content, context_id: contextId },
},
]);
} else {
console.error("Invalid embedding:", embedding);
}
} else {
console.error("Environment not found");
return c.json({ error: "Environment bindings inaccessible" }, 500);
}
...
this block always fails my wrangler-toml
[ai]
binding = "AI"

[[vectorize]]
binding = "VECTORIZE"
index_name = "dropbase-index"
[ai]
binding = "AI"

[[vectorize]]
binding = "VECTORIZE"
index_name = "dropbase-index"
17 replies
BABetter Auth
Created by Dev on 1/17/2025 in #help
Is Better Auth edge compatible?
I'm trying to deploy my nextjs-hono-backend application on cloudflare pages. It builds successfully but on preview, it returns the following errors in the terminal
✨ Compiled Worker successfully
✨ Parsed 1 valid header rule.
Using vars defined in .dev.vars
⎔ Starting local server...
[wrangler:inf] Ready on http://localhost:8788

✘ [ERROR] Better Auth:error INTERNAL_SERVER_ERROR NeonDbError: Error connecting to database: XMLHttpRequest is not defined

...

✘ [ERROR] Better Auth:error INTERNAL_SERVER_ERROR [f [BetterCallAPIError]: API Error: INTERNAL_SERVER_ERROR Failed to get session] {

status: 'INTERNAL_SERVER_ERROR',
headers: Headers(0) { [immutable]: false },
body: { message: 'Failed to get session', code: 'FAILED_TO_GET_SESSION' },
[cause]: { message: 'Failed to get session', code: 'FAILED_TO_GET_SESSION' }
}

[wrangler:inf] GET /api/auth/get-session 500 Internal Server Error (153ms)
[wrangler:inf] GET / 200 OK (194ms)

✘ [ERROR] ReferenceError: XMLHttpRequest is not defined

[wrangler:inf] GET /favicon-32x32.png 200 OK (20ms)
[wrangler:inf] GET /site.webmanifest 500 Internal Server Error (24ms)
✘ [ERROR] ReferenceError: XMLHttpRequest is not defined

[wrangler:inf] GET / 500 Internal Server Error (23ms)
✘ [ERROR] ReferenceError: XMLHttpRequest is not defined
✨ Compiled Worker successfully
✨ Parsed 1 valid header rule.
Using vars defined in .dev.vars
⎔ Starting local server...
[wrangler:inf] Ready on http://localhost:8788

✘ [ERROR] Better Auth:error INTERNAL_SERVER_ERROR NeonDbError: Error connecting to database: XMLHttpRequest is not defined

...

✘ [ERROR] Better Auth:error INTERNAL_SERVER_ERROR [f [BetterCallAPIError]: API Error: INTERNAL_SERVER_ERROR Failed to get session] {

status: 'INTERNAL_SERVER_ERROR',
headers: Headers(0) { [immutable]: false },
body: { message: 'Failed to get session', code: 'FAILED_TO_GET_SESSION' },
[cause]: { message: 'Failed to get session', code: 'FAILED_TO_GET_SESSION' }
}

[wrangler:inf] GET /api/auth/get-session 500 Internal Server Error (153ms)
[wrangler:inf] GET / 200 OK (194ms)

✘ [ERROR] ReferenceError: XMLHttpRequest is not defined

[wrangler:inf] GET /favicon-32x32.png 200 OK (20ms)
[wrangler:inf] GET /site.webmanifest 500 Internal Server Error (24ms)
✘ [ERROR] ReferenceError: XMLHttpRequest is not defined

[wrangler:inf] GET / 500 Internal Server Error (23ms)
✘ [ERROR] ReferenceError: XMLHttpRequest is not defined
I dont know if neon is making these XMLHttpRequest or better-auth but since neon is edge compatible, it might be better-auth
7 replies
BABetter Auth
Created by Dev on 12/19/2024 in #bug-reports
Error in signing up using cloudflare d1 database and drizzle orm on nextjs15
I've been trying to make the signup logic work, ive watch so 2 tutorials relating to the same techstack as mine and wrote same code as them but mine doesn't work at all gave same errors on all iterations. this error occurs when i submit the sign-up form, i have nothing in the code defined as "fullSchema" :
ERROR TypeError Cannot read properties of undefined (reading 'fullSchema') Better Auth

at y (.next\server\chunks\node_modules_better-auth_dist_37bdef._.js:5192:33)
(... clipped)
at async Server.requestListener (node_modules\next\dist\server\lib\start-server.js:146:13)

POST /api/auth/sign-up/email?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fregister 500 in 135ms
ERROR TypeError Cannot read properties of undefined (reading 'fullSchema') Better Auth

at y (.next\server\chunks\node_modules_better-auth_dist_37bdef._.js:5192:33)
(... clipped)
at async Server.requestListener (node_modules\next\dist\server\lib\start-server.js:146:13)

POST /api/auth/sign-up/email?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fregister 500 in 135ms
and this error appears in the browser console:
{
"response": {},
"request": {
"baseURL": "http://localhost:3000/api/auth",
"credentials": "include",
"method": "POST",
"plugins": [
{
"id": "redirect",
"name": "Redirect",
"hooks": {}
},
{
"id": "add-current-url",
"name": "Add current URL",
"hooks": {}
},
{
"id": "apply-schema",
"name": "Apply Schema",
"version": "1.0.0"
}
],
"body": "{\"name\":\"dev\",\"email\":\"[email protected]\",\"password\":\"qwerty1234\",\"callbackURL\":\"/verify-email\"}",
"url": "http://localhost:3000/api/auth/sign-up/email?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fsign-up",
"headers": {},
"signal": {}
},
"error": {
"status": 500,
"statusText": "Internal Server Error"
}
}
{
"response": {},
"request": {
"baseURL": "http://localhost:3000/api/auth",
"credentials": "include",
"method": "POST",
"plugins": [
{
"id": "redirect",
"name": "Redirect",
"hooks": {}
},
{
"id": "add-current-url",
"name": "Add current URL",
"hooks": {}
},
{
"id": "apply-schema",
"name": "Apply Schema",
"version": "1.0.0"
}
],
"body": "{\"name\":\"dev\",\"email\":\"[email protected]\",\"password\":\"qwerty1234\",\"callbackURL\":\"/verify-email\"}",
"url": "http://localhost:3000/api/auth/sign-up/email?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fsign-up",
"headers": {},
"signal": {}
},
"error": {
"status": 500,
"statusText": "Internal Server Error"
}
}
versions: "better-auth": "^1.0.22" "next": "15.1.0" "drizzle-orm": "^0.38.2" "wrangler": "^3.98.0" any help is appreciated!
10 replies
KKinde
Created by Dev on 7/15/2024 in #💻┃support
Session cookie does not persist after reload in React SDK
main.js:
<KindeProvider
clientId={import.meta.env.VITE_KINDE_CLIENT_ID}
domain={import.meta.env.VITE_KINDE_DOMAIN}
{redirectUri}
{redirectUri.replace("/dashboard", "/")}
>
<ThemeProvider>
<App />
</ThemeProvider>
</KindeProvider>
<KindeProvider
clientId={import.meta.env.VITE_KINDE_CLIENT_ID}
domain={import.meta.env.VITE_KINDE_DOMAIN}
{redirectUri}
{redirectUri.replace("/dashboard", "/")}
>
<ThemeProvider>
<App />
</ThemeProvider>
</KindeProvider>
i have setup admin subdomain in my site, thats why the redirectUri and logoutUri is different from what's defined in the react setup docs So, when i try to login using this setting, it logs in for a moment but when i reload, it logs me out immediately i had a look in the applications tab in the browser console, the cookies had some enduser_session_id field in it, and when i reload, this field vanishes I tried using isDangerouslyUseLocalStorage={true} in the above setting, it kept me logged in until i manually log out, the local storage had kinde_refresh_token this time and if i log out, the kinde_refresh_token & enduser_session_id vanishes from local storage and cookies resp. I cannot keep using isDangerouslyUseLocalStorage={true} as it is not secure, and i'm wondering why the kinde_refresh_token not getting saved in the cookie instead of local storage? is this a bug? if not is there a workaround to make it work
2 replies