ERROR [Better Auth]: State not found undefined

I'm getting this error in this repo—the
beta
branch
. I'm setting this SvelteKit project up to be deployed to Cloudflare. I implemented GitHub auth (the App way, not OAuth way). Everything works well, up until when GitHub redirects back to the app, then I get the page in the screenshot attached.

@glassy had a similar issue, but his hint at the solution isn't quite clear to me:
As noted above, I forgot to include the query string when re-constructing the URL.
 
In the fastify example (https://www.better-auth.com/docs/integrations/fastify) they do:

const url = new URL(request.url, `http://${request.headers.host}`);


For my framework (which is uwebsockets based) the req.getUrl() method doesn't include the query string (the part after '?'), I had to get that separately from req.getQuery() and append it to the url as the input to the new URL call 


I'd appreciate any help on this.
Screenshot_2025-07-19_at_7.49.44_PM.png
Solution
GitHub
Is this suited for github? Yes, this is suited for github To Reproduce Bug Description Following the official Better Auth documentation for setting up GitHub OAuth in SvelteKit results in a "S...
Was this page helpful?