-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Closed
Labels
authAll thing Supabase Auth relatedAll thing Supabase Auth relatedbugSomething isn't workingSomething isn't workingexternal-issuepr-openedA PR has been opened to resolve the issueA PR has been opened to resolve the issueto-triage
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
In Next.js when using signInWithOAuth with the x provider and a redirectTo option, authentication fails:
const { error } = await supabase.auth.signInWithOAuth({
provider: 'x',
options: {
redirectTo: `${window.location.origin}/auth/callback`,
},
})Error response:
{
"errors": [
{
"error": "invalid_request",
"error_description": "Redirect is requested.",
"redirect_uri": "https://lrdewyqzapfmcpbdxfpb.supabase.co/auth/v1/callback?error=invalid_request&state="
}
]
}To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Create an X OAuth 2.0 app in the X Developer Portal
- Configure Supabase project with correct OAuth 2.0 Client ID and Client Secret
- Add callback URL to X app settings:
https://<project-ref>.supabase.co/auth/v1/callback - Install dependencies:
{
"@supabase/ssr": "^0.8.0",
"@supabase/supabase-js": "^2.89.0",
"next": "16.1.1",
"react": "19.2.3",
"react-dom": "19.2.3"
}- Initialize Supabase client:
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
)- Attempt to sign in with
redirectTooption:
const { error } = await supabase.auth.signInWithOAuth({
provider: 'x',
options: {
redirectTo: `${window.location.origin}/auth/callback`,
},
})Expected behavior
The x provider should handle redirectTo the same way as other OAuth providers, redirecting to the specified callback URL after successful authorization.
Screenshots
System information
- OS: macOS, Windows
- Browser (if applies) Chrome, Edge
- Dependencies:
{
"@supabase/ssr": "^0.8.0",
"@supabase/supabase-js": "^2.89.0",
"next": "16.1.1",
"react": "19.2.3",
"react-dom": "19.2.3"
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
authAll thing Supabase Auth relatedAll thing Supabase Auth relatedbugSomething isn't workingSomething isn't workingexternal-issuepr-openedA PR has been opened to resolve the issueA PR has been opened to resolve the issueto-triage