The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: fix Next.js create client docs to match fix in ssr auth docs (#27659)
Erik Petersen862f6075fb0f
diff --git a/apps/docs/content/guides/auth/server-side/creating-a-client.mdx b/apps/docs/content/guides/auth/server-side/creating-a-client.mdxindex 256c31cb868..06d1eac5825 100644--- a/apps/docs/content/guides/auth/server-side/creating-a-client.mdx+++ b/apps/docs/content/guides/auth/server-side/creating-a-client.mdx@@ -203,11 +203,19 @@ export async function middleware(request: NextRequest) {// supabase.auth.getUser(). A simple mistake could make it very hard to debug// issues with users being randomly logged out.- const { data: user, error } = await supabase.auth.getUser()-- if (!user) {+ const {+ data: { user },+ } = await supabase.auth.getUser()++ if (+ !user &&+ !request.nextUrl.pathname.startsWith('/login') &&+ !request.nextUrl.pathname.startsWith('/auth')+ ) {// no user, potentially respond by redirecting the user to the login page- return NextResponse.redirect('/login')+ const url = request.nextUrl.clone()+ url.pathname = '/login'+ return NextResponse.redirect(url)}// IMPORTANT: You *must* return the supabaseResponse object as it is. If you'rediff --git a/apps/docs/content/guides/auth/server-side/nextjs.mdx b/apps/docs/content/guides/auth/server-side/nextjs.mdxindex 43068495d2b..fe9f3f98ab5 100644--- a/apps/docs/content/guides/auth/server-side/nextjs.mdx+++ b/apps/docs/content/guides/auth/server-side/nextjs.mdx@@ -247,7 +247,11 @@ export async function updateSession(request: NextRequest) {data: { user },} = await supabase.auth.getUser()- if (!user && !request.nextUrl.pathname.startsWith('/login')) {+ if (+ !user &&+ !request.nextUrl.pathname.startsWith('/login') &&+ !request.nextUrl.pathname.startsWith('/auth')+ ) {// no user, potentially respond by redirecting the user to the login pageconst url = request.nextUrl.clone()url.pathname = '/login'