New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow State not found #1341
Comments
What libraries do you use with NextJS? Please send us a code snippet that includes the initialization of the Supabase client. |
I'm initializing the client like this: import { createBrowserClient } from "@supabase/ssr";
const supabase = createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
); And using like this: const { error } = await supabase.auth.signInWithOAuth({
provider: "google",
options: {
redirectTo: `${window.location.origin}/auth/callback?next=${window.location.href}`,
queryParams: {
access_type: "offline",
prompt: "consent",
},
},
}); I think I copy-pasted code from https://supabase.com/docs/guides/auth/server-side/oauth-with-pkce-flow-for-ssr to my import { cookies } from "next/headers";
import { NextResponse } from "next/server";
import { type CookieOptions, createServerClient } from "@supabase/ssr";
export async function GET(request: Request) {
const { searchParams, origin } = new URL(request.url);
const code = searchParams.get("code");
// if "next" is in param, use it as the redirect URL
const next = searchParams.get("next") ?? "/";
if (code) {
const cookieStore = cookies();
const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
get(name: string) {
return cookieStore.get(name)?.value;
},
set(name: string, value: string, options: CookieOptions) {
cookieStore.set({ name, value, ...options });
},
remove(name: string, options: CookieOptions) {
cookieStore.delete({ name, ...options });
},
},
}
);
try {
if (!code) {
throw new Error(
`code param is missing in ${
request.url
}; all params: ${JSON.stringify(searchParams)}`
);
}
const { error } = await supabase.auth.exchangeCodeForSession(code);
if (!error) {
return NextResponse.redirect(`${next}`);
} else {
console.error(error);
return NextResponse.redirect(`${origin}/?error=${error.message}`);
}
} catch (error: unknown) {
console.log(error);
if (error instanceof Error) {
return NextResponse.redirect(`${origin}/?error=${error.message}`);
} else {
return NextResponse.redirect(`${origin}/?error=${error?.toString()}`);
}
}
}
// return the user to an error page with instructions
return NextResponse.redirect(`${origin}/auth/auth-code-error`);
} |
I'm also experiencing the same thing. Some of my google user aren't able to login because of the same problem. @Phil9l were you able to get around this issue? |
No, unfortunately, not. More and more users are complaining about it. It's getting pretty critical for us at this point. |
If you are able to reproduce, please send us a HAR recording if possible. You can use https://supabase.help if you want to keep that private, just mention this issue when opening a support ticket. Some causes of why the error could be happening:
As you mentioned self-hosting, please provide us with details of the versions you're using on the server and configuration options related to this. |
We have seen that too, but only occasionally and I cannot reproduce that (hence can't share more than just these):
|
Bug report
Describe the bug
I am using self-hosted supabase with gotrue and next js for auth. A few users can't login to the app because they get redirected to the following page every time they try to sign in with google.
I haven't found anything unusual about these users.
On the client side I call
To Reproduce
I haven't found why it happens to these specific users. They are using mobile chrome and using the same auth flow as other users. They tried logging in using multiple different google accounts.
Flow State not found
error.Expected behavior
Users can log in to the app.
Screenshots
https://imgur.com/a/D9WGyMH
System information
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36
The text was updated successfully, but these errors were encountered: