Devendra Singh
Devendra Singh
Explore posts from servers
DTDrizzle Team
Created by Devendra Singh on 1/18/2025 in #help
XMLHttpRequest is not defined
I'm trying to deploy my nextjs-hono-backend application on cloudflare pages. im using drizzle adapter with neon-postgres in better-auth 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
this XMLHttpRequest is likely being made from the drizzle adapter and not better-auth
2 replies
KKinde
Created by Devendra Singh 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