You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
name ==> sb-yelbdeiefeqnignhtxkc-auth-token
nameValue ==> undefined
name ==> sb-yelbdeiefeqnignhtxkc-auth-token.0
nameValue ==> undefined
real name of cookie is something different
I am using Google and github as provider. and this is what my code look like full repo an opensource portfolio & resume builder
src/middleware.ts
import { updateSession } from "@/utils/supabase/middleware";
import { type NextRequest } from "next/server";
export async function middleware(request: NextRequest) {
return await updateSession(request);
}
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
* Feel free to modify this pattern to include more paths.
*/
"/((?!_next/static|_next/image|favicon.ico|p|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
],
};
src\utils\supabase\client.ts
import { createBrowserClient } from "@supabase/ssr";
export function createClient() {
return createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
);
}
src\utils\supabase\server.ts
"use server";
import { createServerClient, type CookieOptions } from "@supabase/ssr";
import { cookies } from "next/headers";
export default async function createClient() {
const cookieStore = cookies();
return 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) {
try {
cookieStore.set({ name, value, ...options });
} catch (error) {
// The `set` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
remove(name: string, options: CookieOptions) {
try {
cookieStore.set({ name, value: "", ...options });
} catch (error) {
// The `delete` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
},
}
);
}
Hi! Is there a specific reason why calling auth.getUser() in your protected route to see if they are logged in and then kicking them out is not an option? It seems like the guide you linked does exactly that in the last step. afaik there won't be a user before a code exchange is done, which looks like that is the case in the attached picture because I only see the code challenge.
We're also experiencing a similar problem. On our server, we're having the following check:
const authenticatedUser = await this.supabaseAdminClient.auth.getUser(jwtToken)
if (!authenticatedUser.data.user) {
this.logger.debug('No user is associated with the access token!')
return false
}
However, sometimes, even though we are using a valid jwt, await this.supabaseAdminClient.auth.getUser(jwtToken) is returning null.
Bug report
Describe the bug
error, even if I followed everything in doc. https://supabase.com/docs/guides/auth/server-side/nextjs
my observation:
logs:
real name of cookie is something different
I am using Google and github as provider. and this is what my code look like full repo an opensource portfolio & resume builder
src/middleware.ts
src\utils\supabase\client.ts
src\utils\supabase\server.ts
src\utils\supabase\middleware.ts
src\app\auth\callback\route.ts
onClick function signinWithSocial("google" | "github")
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
in the middleware i should get the user value, by which i can check and redirect someone if they are not loged in
Screenshots
If applicable, add screenshots to help explain your problem.
System information
"@supabase/supabase-js": "^2.43.1",
Additional context
I have setuped oauth provider in supabase dashboard successfully, so that wont be any problem
The text was updated successfully, but these errors were encountered: