[GH-ISSUE #2149] oauth not working in sveltekit? wierd cancelled network request?(firefox, chromium, everywhere) #26391

Closed
opened 2026-04-17 16:55:39 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @blurskye on GitHub (Apr 6, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2149

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

i have followed the guide on better-auth.com

bun sv create test
bunx prisma init
bun add @prisma/client better-auth
# edited schema.prisma(else it wont be able to generate, better auth cli doesnt work without that), 
bunx prisma generate && bunx prisma migrate dev
bunx @better-auth/cli@latest generate

i added hooks.server.ts and auth.ts, created a basic login page in /routes/+page.svelte

Image

Image

what does this even mean, i have verified it is not cors error, that shows up as cors error, not cancelled

but following the requested link in the picture manually, like opening that link in another tab works

Image

i have attached the sveltekit project below

test.zip

to test add a .env file

BETTER_AUTH_SECRET=ADdaOmg0iDzNfjBBUgrLn7fqyhLk7dy9
BETTER_AUTH_URL=http://localhost:3000 #Base URL of your app
GOOGLE_CLIENT_ID=googleclint
GOOGLE_CLIENT_SECRET=secret

and
bun i && bun dev --port 3000

Current vs. Expected behavior

it should just login as expected

What version of Better Auth are you using?

1.2.5

Provide environment information

- Os      = Arch linux
- Browser = brave, firefox

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();
export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: "sqlite", // or "mysql", "postgresql", ...etc
  }),
  emailAndPassword: {
    enabled: true
  },
  socialProviders: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID as string,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
    },
  },
});

Additional context

No response

Originally created by @blurskye on GitHub (Apr 6, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2149 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce i have followed the guide on better-auth.com ``` bun sv create test bunx prisma init bun add @prisma/client better-auth # edited schema.prisma(else it wont be able to generate, better auth cli doesnt work without that), bunx prisma generate && bunx prisma migrate dev bunx @better-auth/cli@latest generate ``` i added hooks.server.ts and auth.ts, created a basic login page in /routes/+page.svelte ![Image](https://github.com/user-attachments/assets/f5687853-ab11-4cda-9a57-96f2f8c737f2) ![Image](https://github.com/user-attachments/assets/90e9aff4-5bdc-4b7b-942a-bc24a67f7c9d) what does this even mean, i have verified it is not cors error, that shows up as cors error, not cancelled but following the requested link in the picture manually, like opening that link in another tab works ![Image](https://github.com/user-attachments/assets/a4f5b8a2-a0f7-4757-999f-b4f057976424) i have attached the sveltekit project below [test.zip](https://github.com/user-attachments/files/19626349/test.zip) to test add a .env file ``` BETTER_AUTH_SECRET=ADdaOmg0iDzNfjBBUgrLn7fqyhLk7dy9 BETTER_AUTH_URL=http://localhost:3000 #Base URL of your app GOOGLE_CLIENT_ID=googleclint GOOGLE_CLIENT_SECRET=secret ``` and `bun i && bun dev --port 3000` ### Current vs. Expected behavior it should just login as expected ### What version of Better Auth are you using? 1.2.5 ### Provide environment information ```bash - Os = Arch linux - Browser = brave, firefox ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "sqlite", // or "mysql", "postgresql", ...etc }), emailAndPassword: { enabled: true }, socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, }, }, }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 16:55:39 -05:00
Author
Owner

@elansx commented on GitHub (Apr 6, 2025):

Did you add correct origins and redirect URI in Google Cloud when setting up?

<!-- gh-comment-id:2781317869 --> @elansx commented on GitHub (Apr 6, 2025): Did you add correct origins and redirect URI in Google Cloud when setting up?
Author
Owner

@blurskye commented on GitHub (Apr 6, 2025):

yes, i did that, ig thats why it is working when i copy paste the (cancelled) request's requested url

please check out attached test.zip with the minimal sveltekit betterauth auth test, it appears to not be working

<!-- gh-comment-id:2781331387 --> @blurskye commented on GitHub (Apr 6, 2025): yes, i did that, ig thats why it is working when i copy paste the (cancelled) request's requested url please check out attached test.zip with the minimal sveltekit betterauth auth test, it appears to not be working
Author
Owner

@blurskye commented on GitHub (Apr 7, 2025):

@elansx figured out that it is tailwind's fault,any idea why not adding tailwind makes it work, if i add tailwind, better-auth oauth no longer works

<!-- gh-comment-id:2782200980 --> @blurskye commented on GitHub (Apr 7, 2025): @elansx figured out that it is tailwind's fault,any idea why not adding tailwind makes it work, if i add tailwind, better-auth oauth no longer works
Author
Owner

@blurskye commented on GitHub (Apr 7, 2025):

it works with tailwind cli, watching project and updating output.css, but it doesnt work when tailwind is added via vite, cursed bug

<!-- gh-comment-id:2782274690 --> @blurskye commented on GitHub (Apr 7, 2025): it works with tailwind cli, watching project and updating output.css, but it doesnt work when tailwind is added via vite, cursed bug
Author
Owner

@Bekacru commented on GitHub (May 5, 2025):

Feel free to re-open this if it's realted to better auth. But I think it's something related your vite dev server

<!-- gh-comment-id:2852103568 --> @Bekacru commented on GitHub (May 5, 2025): Feel free to re-open this if it's realted to better auth. But I think it's something related your vite dev server
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26391