Skip to content

Commit

Permalink
Add experimental routing
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Nov 21, 2024
1 parent 3766be7 commit 6c81115
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/supabase/src/client/client.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { createBrowserClient } from "@supabase/ssr";
import type { Database } from "../types";

export const createClient = () =>
createBrowserClient<Database>(
export const createClient = () => {
return createBrowserClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
global: {
headers: {
// https://supabase.com/docs/guides/platform/read-replicas#experimental-routing
"sb-lb-routing-mode": "alpha-all-services",
},
},
},
);
};
6 changes: 6 additions & 0 deletions packages/supabase/src/client/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export async function updateSession(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
global: {
headers: {
// https://supabase.com/docs/guides/platform/read-replicas#experimental-routing
"sb-lb-routing-mode": "alpha-all-services",
},
},
cookies: {
get(name: string) {
return request.cookies.get(name)?.value;
Expand Down
2 changes: 2 additions & 0 deletions packages/supabase/src/client/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export const createClient = (options?: CreateClientOptions) => {
headers: {
// Pass user agent from browser
"user-agent": headers().get("user-agent") as string,
// https://supabase.com/docs/guides/platform/read-replicas#experimental-routing
"sb-lb-routing-mode": "alpha-all-services",
},
},
},
Expand Down

0 comments on commit 6c81115

Please sign in to comment.