-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6d2db4
commit 59c3a4c
Showing
24 changed files
with
181 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
refine-nextjs/plugins/data-provider-supabase/src/middleware.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { updateSession } from "@/utils/supabase/middleware"; | ||
import type { NextRequest } from "next/server"; | ||
|
||
export async function middleware(request: NextRequest) { | ||
const result = await updateSession(request); | ||
return result; | ||
} | ||
|
||
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|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)", | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 15 additions & 6 deletions
21
...nextjs/plugins/data-provider-supabase/src/providers/auth-provider/auth-provider.server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
refine-nextjs/plugins/data-provider-supabase/src/providers/auth-provider/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './auth-provider' | ||
export * from './auth-provider.server' | ||
export * from "./auth-provider.client"; | ||
export * from "./auth-provider.server"; |
4 changes: 2 additions & 2 deletions
4
refine-nextjs/plugins/data-provider-supabase/src/providers/data-provider/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
"use client"; | ||
|
||
import { dataProvider as dataProviderSupabase } from "@refinedev/supabase"; | ||
import { supabaseClient } from "@utility/supabase-client"; | ||
import { supabaseBrowserClient } from "@utils/supabase/client"; | ||
|
||
export const dataProvider = dataProviderSupabase(supabaseClient); | ||
export const dataProvider = dataProviderSupabase(supabaseBrowserClient); |
14 changes: 0 additions & 14 deletions
14
refine-nextjs/plugins/data-provider-supabase/src/utility/supabase-client.ts
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
refine-nextjs/plugins/data-provider-supabase/src/utils/supabase/client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { createBrowserClient } from "@supabase/ssr"; | ||
import { SUPABASE_KEY, SUPABASE_URL } from "./constants"; | ||
|
||
export const supabaseBrowserClient = createBrowserClient( | ||
SUPABASE_URL, | ||
SUPABASE_KEY, | ||
{ | ||
db: { | ||
schema: "public", | ||
}, | ||
}, | ||
); |
3 changes: 3 additions & 0 deletions
3
refine-nextjs/plugins/data-provider-supabase/src/utils/supabase/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const SUPABASE_URL = "https://iwdfzvfqbtokqetmbmbp.supabase.co"; | ||
export const SUPABASE_KEY = | ||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYzMDU2NzAxMCwiZXhwIjoxOTQ2MTQzMDEwfQ._gr6kXGkQBi9BM9dx5vKaNKYj_DJN1xlkarprGpM_fU"; |
57 changes: 57 additions & 0 deletions
57
refine-nextjs/plugins/data-provider-supabase/src/utils/supabase/middleware.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { CookieOptions, createServerClient } from "@supabase/ssr"; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { SUPABASE_KEY, SUPABASE_URL } from "./constants"; | ||
|
||
export async function updateSession(request: NextRequest) { | ||
let response = NextResponse.next({ | ||
request: { | ||
headers: request.headers, | ||
}, | ||
}); | ||
|
||
const supabase = createServerClient(SUPABASE_URL, SUPABASE_KEY, { | ||
cookies: { | ||
get(name: string) { | ||
return request.cookies.get(name)?.value; | ||
}, | ||
set(name: string, value: string, options: CookieOptions) { | ||
request.cookies.set({ | ||
name, | ||
value, | ||
...options, | ||
}); | ||
response = NextResponse.next({ | ||
request: { | ||
headers: request.headers, | ||
}, | ||
}); | ||
response.cookies.set({ | ||
name, | ||
value, | ||
...options, | ||
}); | ||
}, | ||
remove(name: string, options: CookieOptions) { | ||
request.cookies.set({ | ||
name, | ||
value: "", | ||
...options, | ||
}); | ||
response = NextResponse.next({ | ||
request: { | ||
headers: request.headers, | ||
}, | ||
}); | ||
response.cookies.set({ | ||
name, | ||
value: "", | ||
...options, | ||
}); | ||
}, | ||
}, | ||
}); | ||
|
||
await supabase.auth.getUser(); | ||
|
||
return response; | ||
} |
33 changes: 33 additions & 0 deletions
33
refine-nextjs/plugins/data-provider-supabase/src/utils/supabase/server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { CookieOptions, createServerClient } from "@supabase/ssr"; | ||
import { cookies } from "next/headers"; | ||
import { SUPABASE_KEY, SUPABASE_URL } from "./constants"; | ||
|
||
export const createSupabaseServerClient = () => { | ||
const cookieStore = cookies(); | ||
|
||
return createServerClient(SUPABASE_URL, SUPABASE_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. | ||
} | ||
}, | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.