The first commit, the core and all files is adding to repo
This commit is contained in:
32
proxy.ts
Normal file
32
proxy.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { createServerClient } from "@supabase/ssr";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
export async function proxy(request: NextRequest) {
|
||||
let response = NextResponse.next({ request });
|
||||
if (!process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY) return response;
|
||||
const client = createServerClient(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY,
|
||||
{
|
||||
cookies: {
|
||||
getAll: () => request.cookies.getAll(),
|
||||
setAll: (values) => {
|
||||
values.forEach(({ name, value }) => request.cookies.set(name, value));
|
||||
response = NextResponse.next({ request });
|
||||
values.forEach(({ name, value, options }) =>
|
||||
response.cookies.set(name, value, options),
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
await client.auth.getUser();
|
||||
return response;
|
||||
}
|
||||
export const config = {
|
||||
matcher: [
|
||||
"/dashboard/:path*",
|
||||
"/moderation/:path*",
|
||||
"/pair",
|
||||
"/api/v1/:path*",
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user