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
- Deployed a fork of
open-agents to Vercel (e.g., domain open-agents-awingmawe.vercel.app).
- Created a new OAuth2 Application in Vercel Dashboard (Team/Personal Settings > Apps).
- Added the callback URL exactly as specified:
https://open-agents-awingmawe.vercel.app/api/auth/callback/vercel.
- Generated a Client Secret.
- Added
NEXT_PUBLIC_VERCEL_APP_CLIENT_ID and VERCEL_APP_CLIENT_SECRET to the project's Environment Variables.
- Triggered a Redeploy of the Vercel project to ensure the new environment variables take effect.
- Opened the app and clicked "Sign in with Vercel".
- Redirected to the Vercel OAuth authorization page (e.g.,
https://vercel.com/oauth/authorize?...).
- 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?
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_uriparameter exactly matches the configured Authorization Callback URL in the Vercel App settings.To Reproduce
open-agentsto Vercel (e.g., domainopen-agents-awingmawe.vercel.app).https://open-agents-awingmawe.vercel.app/api/auth/callback/vercel.NEXT_PUBLIC_VERCEL_APP_CLIENT_IDandVERCEL_APP_CLIENT_SECRETto the project's Environment Variables.https://vercel.com/oauth/authorize?...).Additional Context
redirect_uriparameter in the failing URL is URL-encoded but decodes to exactlyhttps://open-agents-awingmawe.vercel.app/api/auth/callback/vercel, which perfectly matches the setting.BETTER_AUTH_SECRETandPOSTGRES_URLare configured and working.Is there a hidden requirement for the callback URL, or an issue with how
better-authconstructs theredirect_uridynamically based on the host?