File tree Expand file tree Collapse file tree 4 files changed +12
-21
lines changed
apps/website/app/utils/supabase
packages/database/supabase/functions/create-space Expand file tree Collapse file tree 4 files changed +12
-21
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ import { createServerClient } from "@supabase/ssr";
22import { NextResponse , type NextRequest } from "next/server" ;
33import { envContents } from "@repo/database/dbDotEnv" ;
44
5+ // This would allow to create Next pages gated by a login middleware,
6+ // as described here: https://nextjs.org/docs/app/api-reference/file-conventions/middleware
7+ // Not usable yet, waiting for ENG-373
58// Inspired by https://supabase.com/ui/docs/nextjs/password-based-auth
69
710export const updateSession = async ( request : NextRequest ) => {
@@ -17,10 +20,8 @@ export const updateSession = async (request: NextRequest) => {
1720
1821 const supabase = createServerClient ( supabaseUrl , supabaseKey , {
1922 cookies : {
20- getAll ( ) {
21- return request . cookies . getAll ( ) ;
22- } ,
23- setAll ( cookiesToSet ) {
23+ getAll : ( ) => request . cookies . getAll ( ) ,
24+ setAll : ( cookiesToSet ) => {
2425 cookiesToSet . forEach ( ( { name, value } ) =>
2526 request . cookies . set ( name , value ) ,
2627 ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { cookies } from "next/headers";
33import type { Database } from "@repo/database/dbTypes" ;
44import { envContents } from "@repo/database/dbDotEnv" ;
55
6+ // This is a supabase client to be used in a server process such as NextJS
67// Inspired by https://supabase.com/ui/docs/nextjs/password-based-auth
78
89export const createClient = async ( ) => {
@@ -18,16 +19,16 @@ export const createClient = async () => {
1819 // following https://supabase.com/docs/guides/auth/server-side/creating-a-client?queryGroups=environment&environment=server
1920 return createServerClient < Database > ( supabaseUrl , supabaseKey , {
2021 cookies : {
21- getAll ( ) {
22+ getAll : ( ) => {
2223 return cookieStore . getAll ( ) ;
2324 } ,
24- setAll (
25+ setAll : (
2526 cookiesToSet : {
2627 name : string ;
2728 value : string ;
2829 options : CookieOptions ;
2930 } [ ] ,
30- ) {
31+ ) => {
3132 try {
3233 cookiesToSet . forEach (
3334 ( {
Original file line number Diff line number Diff line change @@ -220,6 +220,9 @@ Deno.serve(async (req) => {
220220 headers : { "Content-Type" : "application/json" } ,
221221 } ) ;
222222 }
223+ // note: If we wanted this to be bound by permissions, we'd set the following options:
224+ // { global: { headers: { Authorization: req.headers.get('Authorization')! } } }
225+ // But the point here is to bypass RLS
223226 const supabase : DGSupabaseClient = createClient ( url , key ) ;
224227
225228 const { data, error } = await processAndGetOrCreateSpace ( supabase , input ) ;
You can’t perform that action at this time.
0 commit comments