From 7f4bfb15e52999478b91a7f4d7c80cf041f9e0a2 Mon Sep 17 00:00:00 2001 From: Giancarlo Buomprisco Date: Wed, 29 May 2024 09:33:43 +0700 Subject: [PATCH] Replace createServerClient with createClient in multiple files (#30) The `createServerClient` function has been replaced with the `createClient` function in the `server-actions.client.ts`, `route-handler.client.ts`, and `server-component.client.ts` files. This includes adding necessary import statements for `createClient` and adjusting the options passed to it, including `persistSession`, `detectSessionInUrl`, and `autoRefreshToken`. --- apps/web/package.json | 4 ++-- .../src/clients/route-handler.client.ts | 7 ++++-- .../src/clients/server-actions.client.ts | 7 ++++-- .../src/clients/server-component.client.ts | 6 +++-- pnpm-lock.yaml | 22 +++++++++---------- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/apps/web/package.json b/apps/web/package.json index 217bc7a41..35a5d6404 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -56,7 +56,7 @@ "@radix-ui/react-icons": "^1.3.0", "@supabase/supabase-js": "^2.43.4", "@tanstack/react-query": "5.40.0", - "@tanstack/react-query-next-experimental": "^5.39.0", + "@tanstack/react-query-next-experimental": "^5.40.0", "@tanstack/react-table": "^8.17.3", "date-fns": "^3.6.0", "lucide-react": "^0.379.0", @@ -86,7 +86,7 @@ "dotenv-cli": "^7.4.2", "eslint": "^8.57.0", "prettier": "^3.2.5", - "supabase": "^1.169.6", + "supabase": "^1.169.8", "tailwindcss": "3.4.3", "typescript": "^5.4.5" }, diff --git a/packages/supabase/src/clients/route-handler.client.ts b/packages/supabase/src/clients/route-handler.client.ts index 85ea0b079..076147ae7 100644 --- a/packages/supabase/src/clients/route-handler.client.ts +++ b/packages/supabase/src/clients/route-handler.client.ts @@ -3,6 +3,8 @@ import 'server-only'; import { unstable_noStore as noStore } from 'next/cache'; import { cookies } from 'next/headers'; +import { createClient } from '@supabase/supabase-js'; + import type { CookieOptions } from '@supabase/ssr'; import { createServerClient } from '@supabase/ssr'; @@ -31,11 +33,12 @@ export function getSupabaseRouteHandlerClient( if (params.admin) { warnServiceRoleKeyUsage(); - return createServerClient(keys.url, serviceRoleKey, { + return createClient(keys.url, serviceRoleKey, { auth: { persistSession: false, + autoRefreshToken: false, + detectSessionInUrl: false, }, - cookies: {}, }); } diff --git a/packages/supabase/src/clients/server-actions.client.ts b/packages/supabase/src/clients/server-actions.client.ts index c57f479af..6bf8d2d36 100644 --- a/packages/supabase/src/clients/server-actions.client.ts +++ b/packages/supabase/src/clients/server-actions.client.ts @@ -3,6 +3,8 @@ import 'server-only'; import { unstable_noStore as noStore } from 'next/cache'; import { cookies } from 'next/headers'; +import { createClient } from '@supabase/supabase-js'; + import { createServerClient } from '@supabase/ssr'; import { Database } from '../database.types'; @@ -35,11 +37,12 @@ export function getSupabaseServerActionClient< if (admin) { warnServiceRoleKeyUsage(); - return createServerClient(keys.url, serviceRoleKey, { + return createClient(keys.url, serviceRoleKey, { auth: { persistSession: false, + detectSessionInUrl: false, + autoRefreshToken: false, }, - cookies: {}, }); } diff --git a/packages/supabase/src/clients/server-component.client.ts b/packages/supabase/src/clients/server-component.client.ts index 45a300d7a..63bd26f1b 100644 --- a/packages/supabase/src/clients/server-component.client.ts +++ b/packages/supabase/src/clients/server-component.client.ts @@ -3,6 +3,8 @@ import 'server-only'; import { unstable_noStore as noStore } from 'next/cache'; import { cookies } from 'next/headers'; +import { createClient } from '@supabase/supabase-js'; + import { createServerClient } from '@supabase/ssr'; import { Database } from '../database.types'; @@ -30,12 +32,12 @@ export function getSupabaseServerComponentClient( if (params.admin) { warnServiceRoleKeyUsage(); - return createServerClient(keys.url, serviceRoleKey, { + return createClient(keys.url, serviceRoleKey, { auth: { persistSession: false, autoRefreshToken: false, + detectSessionInUrl: false, }, - cookies: {}, }); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8cc9c170b..7d90d59bc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -127,8 +127,8 @@ importers: specifier: 5.40.0 version: 5.40.0(react@18.3.1) '@tanstack/react-query-next-experimental': - specifier: ^5.39.0 - version: 5.39.0(@tanstack/react-query@5.40.0(react@18.3.1))(next@14.2.3(@opentelemetry/api@1.8.0)(@playwright/test@1.44.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1) + specifier: ^5.40.0 + version: 5.40.0(@tanstack/react-query@5.40.0(react@18.3.1))(next@14.2.3(@opentelemetry/api@1.8.0)(@playwright/test@1.44.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1) '@tanstack/react-table': specifier: ^8.17.3 version: 8.17.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -212,8 +212,8 @@ importers: specifier: ^3.2.5 version: 3.2.5 supabase: - specifier: ^1.169.6 - version: 1.169.6 + specifier: ^1.169.8 + version: 1.169.8 tailwindcss: specifier: 3.4.3 version: 3.4.3(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.4.5)) @@ -3791,10 +3791,10 @@ packages: '@tanstack/query-core@5.40.0': resolution: {integrity: sha512-eD8K8jsOIq0Z5u/QbvOmfvKKE/XC39jA7yv4hgpl/1SRiU+J8QCIwgM/mEHuunQsL87dcvnHqSVLmf9pD4CiaA==} - '@tanstack/react-query-next-experimental@5.39.0': - resolution: {integrity: sha512-96vdfzarxpHjoCn92pOoVRIALZlLkAIpOSsaOzbb3Cxo4KZfofsyEy5PxmBau0zrWV+kV4uFhjelUwOyCNJBDw==} + '@tanstack/react-query-next-experimental@5.40.0': + resolution: {integrity: sha512-JOEKhzjF4juzzB7N6T+dc8BX5a6UxR7IUJBbmfRYa+Ju8Ibamw4W6xVWzZmH1mVd0G3XGuhcIKhba80n+iK+EQ==} peerDependencies: - '@tanstack/react-query': ^5.39.0 + '@tanstack/react-query': ^5.40.0 next: ^13 || ^14 || ^15 react: 18.3.1 @@ -7201,8 +7201,8 @@ packages: engines: {node: '>=16 || 14 >=14.17'} hasBin: true - supabase@1.169.6: - resolution: {integrity: sha512-eSJ1xDFcFqy7EK5TDyC3RwJLzGJyZRgwSAt/CcOHJJ/t+TghS6hfjpyL/R6yqDeGlHo8LBuakdV605EnKSIeZA==} + supabase@1.169.8: + resolution: {integrity: sha512-39vOiK2qZBZXUo0iWIRyJB1DLMk0kNb6iW166uvWRWkKWVaBTOErL510AdD1tVGn+sELsW7erl2vy9qLFmBX0Q==} engines: {npm: '>=8'} hasBin: true @@ -11114,7 +11114,7 @@ snapshots: '@tanstack/query-core@5.40.0': {} - '@tanstack/react-query-next-experimental@5.39.0(@tanstack/react-query@5.40.0(react@18.3.1))(next@14.2.3(@opentelemetry/api@1.8.0)(@playwright/test@1.44.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)': + '@tanstack/react-query-next-experimental@5.40.0(@tanstack/react-query@5.40.0(react@18.3.1))(next@14.2.3(@opentelemetry/api@1.8.0)(@playwright/test@1.44.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)': dependencies: '@tanstack/react-query': 5.40.0(react@18.3.1) next: 14.2.3(@opentelemetry/api@1.8.0)(@playwright/test@1.44.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -15179,7 +15179,7 @@ snapshots: pirates: 4.0.6 ts-interface-checker: 0.1.13 - supabase@1.169.6: + supabase@1.169.8: dependencies: bin-links: 4.0.4 https-proxy-agent: 7.0.4