[GH-ISSUE #1319] TypeError: Invalid URL String when using social provider #8691

Closed
opened 2026-04-13 03:51:12 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @elijahnikov on GitHub (Jan 31, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1319

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Current vs. Expected behavior

am using the Better Auth fork of the Create-T3-Turbo monorepo.

Steps I took to deploy

  1. Set up dev and prod OAuth projects in Discord Dev Portal
  2. Set environment variables in Vercel dashboard, AUTH_DISCORD_ID, AUTH_DISCORD_SECRET and BETTER_AUTH all pointing to the correct environment
  3. I have added the local and deployed URL's to trustedOrigins in auth.ts

This is what my auth config looks like (same exact code from the t3 turbo fork)

Getting the below 500 Internal Server Error when clicking on Sign in with Discord

TypeError: Invalid URL string.
    at (../../node_modules/better-auth/dist/plugins.js:156:0)
    at (../../node_modules/better-auth/dist/chunk-XL5FIR5Z.js:3370:0)
    at (src/app/_components/auth-showcase.tsx:16:24) {
  digest: '1455014963'
}

What version of Better Auth are you using?

1.1.15-beta.7

Provide environment information

- macOs 15.0.1
- Arc Browser Chromium Engine Version 131.0.6778.86

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

Package

Auth config (if applicable)

import { db } from "@acme/db/client";
import { oAuthProxy } from "better-auth/plugins"
import type { BetterAuthOptions } from "better-auth";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { env } from "../env";
import { expo } from "@better-auth/expo";

export const config = {
    database: drizzleAdapter(db, {
        provider: "pg"
    }),
    secret: env.AUTH_SECRET,
    plugins: [oAuthProxy(), expo()],
    socialProviders: {
        discord: {
            clientId: env.AUTH_DISCORD_ID,
            clientSecret: env.AUTH_DISCORD_SECRET,
            redirectURI: "http://localhost:3000/api/auth/callback/discord",
        }
    },
    trustedOrigins: ["exp://", "https://-----.vercel.app", "http://localhost:3000"]
} satisfies BetterAuthOptions

export const auth = betterAuth(config);
export type Session = typeof auth.$Infer.Session

Additional context

No response

Originally created by @elijahnikov on GitHub (Jan 31, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1319 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce - Clone https://github.com/Bekacru/create-t3-turbo - Set up env variables - Push to GitHub and deploy to vercel ### Current vs. Expected behavior am using the Better Auth fork of the Create-T3-Turbo monorepo. Steps I took to deploy 1. Set up dev and prod OAuth projects in Discord Dev Portal 2. Set environment variables in Vercel dashboard, AUTH_DISCORD_ID, AUTH_DISCORD_SECRET and BETTER_AUTH all pointing to the correct environment 3. I have added the local and deployed URL's to trustedOrigins in auth.ts This is what my auth config looks like (same exact code from the t3 turbo fork) Getting the below 500 Internal Server Error when clicking on Sign in with Discord ``` TypeError: Invalid URL string. at (../../node_modules/better-auth/dist/plugins.js:156:0) at (../../node_modules/better-auth/dist/chunk-XL5FIR5Z.js:3370:0) at (src/app/_components/auth-showcase.tsx:16:24) { digest: '1455014963' } ``` ### What version of Better Auth are you using? 1.1.15-beta.7 ### Provide environment information ```bash - macOs 15.0.1 - Arc Browser Chromium Engine Version 131.0.6778.86 ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript import { db } from "@acme/db/client"; import { oAuthProxy } from "better-auth/plugins" import type { BetterAuthOptions } from "better-auth"; import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import { env } from "../env"; import { expo } from "@better-auth/expo"; export const config = { database: drizzleAdapter(db, { provider: "pg" }), secret: env.AUTH_SECRET, plugins: [oAuthProxy(), expo()], socialProviders: { discord: { clientId: env.AUTH_DISCORD_ID, clientSecret: env.AUTH_DISCORD_SECRET, redirectURI: "http://localhost:3000/api/auth/callback/discord", } }, trustedOrigins: ["exp://", "https://-----.vercel.app", "http://localhost:3000"] } satisfies BetterAuthOptions export const auth = betterAuth(config); export type Session = typeof auth.$Infer.Session ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 03:51:12 -05:00
Author
Owner

@Kinfe123 commented on GitHub (Apr 1, 2025):

please make sure to pass the correct url string which really seems an obvious issue as well like BETTER_AUTH_URL='http://locahost:3000/'

<!-- gh-comment-id:2768175144 --> @Kinfe123 commented on GitHub (Apr 1, 2025): please make sure to pass the correct url string which really seems an obvious issue as well like BETTER_AUTH_URL='http://locahost:3000/'
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8691