Skip to content

Vercel OAuth "Invalid URL" error despite exact match in Authorization Callback URLs #874

Description

@awingmawe

Describe the bug

When following the README to set up Vercel OAuth for authentication, the authorization flow fails with an "Invalid URL" error from Vercel, even though the redirect_uri parameter exactly matches the configured Authorization Callback URL in the Vercel App settings.

To Reproduce

  1. Deployed a fork of open-agents to Vercel (e.g., domain open-agents-awingmawe.vercel.app).
  2. Created a new OAuth2 Application in Vercel Dashboard (Team/Personal Settings > Apps).
  3. Added the callback URL exactly as specified: https://open-agents-awingmawe.vercel.app/api/auth/callback/vercel.
  4. Generated a Client Secret.
  5. Added NEXT_PUBLIC_VERCEL_APP_CLIENT_ID and VERCEL_APP_CLIENT_SECRET to the project's Environment Variables.
  6. Triggered a Redeploy of the Vercel project to ensure the new environment variables take effect.
  7. Opened the app and clicked "Sign in with Vercel".
  8. Redirected to the Vercel OAuth authorization page (e.g., https://vercel.com/oauth/authorize?...).
  9. Encountered an "Invalid URL" error from Vercel.

Additional Context

  • The redirect_uri parameter in the failing URL is URL-encoded but decodes to exactly https://open-agents-awingmawe.vercel.app/api/auth/callback/vercel, which perfectly matches the setting.
  • I have tried deleting the Vercel App, creating a new one from scratch, updating the environment variables, and redeploying, but the issue persists.
  • I am on a Hobby plan (though this shouldn't affect OAuth callback limits).
  • The BETTER_AUTH_SECRET and POSTGRES_URL are configured and working.

Is there a hidden requirement for the callback URL, or an issue with how better-auth constructs the redirect_uri dynamically based on the host?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions