fix: remove old stuff and update deps
This commit is contained in:
@@ -1,38 +0,0 @@
|
|||||||
import { NextResponse, type NextRequest } from "next/server";
|
|
||||||
import { createClient } from "@/utils/supabase/middleware";
|
|
||||||
|
|
||||||
export async function middleware(request: NextRequest) {
|
|
||||||
try {
|
|
||||||
// This `try/catch` block is only here for the interactive tutorial.
|
|
||||||
// Feel free to remove once you have Supabase connected.
|
|
||||||
const { supabase, response } = createClient(request);
|
|
||||||
|
|
||||||
// Refresh session if expired - required for Server Components
|
|
||||||
// https://supabase.com/docs/guides/auth/auth-helpers/nextjs#managing-session-with-middleware
|
|
||||||
await supabase.auth.getSession();
|
|
||||||
|
|
||||||
return response;
|
|
||||||
} catch (e) {
|
|
||||||
// If you are here, a Supabase client could not be created!
|
|
||||||
// This is likely because you have not set up environment variables.
|
|
||||||
// Check out http://localhost:3000 for Next Steps.
|
|
||||||
return NextResponse.next({
|
|
||||||
request: {
|
|
||||||
headers: request.headers,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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).*)",
|
|
||||||
],
|
|
||||||
};
|
|
||||||
16
package.json
16
package.json
@@ -9,20 +9,20 @@
|
|||||||
"@radix-ui/react-slot": "^1.0.2",
|
"@radix-ui/react-slot": "^1.0.2",
|
||||||
"@supabase/ssr": "latest",
|
"@supabase/ssr": "latest",
|
||||||
"@supabase/supabase-js": "latest",
|
"@supabase/supabase-js": "latest",
|
||||||
"autoprefixer": "10.4.15",
|
"autoprefixer": "10.4.18",
|
||||||
"geist": "^1.0.0",
|
"geist": "^1.2.2",
|
||||||
"next": "latest",
|
"next": "latest",
|
||||||
"postcss": "8.4.29",
|
"postcss": "8.4.35",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"tailwindcss": "3.3.3",
|
"tailwindcss": "3.4.1",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"typescript": "5.1.3"
|
"typescript": "5.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "20.3.1",
|
"@types/node": "20.11.27",
|
||||||
"@types/react": "18.2.8",
|
"@types/react": "18.2.66",
|
||||||
"@types/react-dom": "18.2.5",
|
"@types/react-dom": "18.2.22",
|
||||||
"encoding": "^0.1.13"
|
"encoding": "^0.1.13"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
import { createBrowserClient } from "@supabase/ssr";
|
|
||||||
|
|
||||||
export const createClient = () =>
|
|
||||||
createBrowserClient(
|
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
||||||
);
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
import { createServerClient, type CookieOptions } from "@supabase/ssr";
|
|
||||||
import { type NextRequest, NextResponse } from "next/server";
|
|
||||||
|
|
||||||
export const createClient = (request: NextRequest) => {
|
|
||||||
// Create an unmodified response
|
|
||||||
let response = NextResponse.next({
|
|
||||||
request: {
|
|
||||||
headers: request.headers,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const supabase = createServerClient(
|
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
||||||
{
|
|
||||||
cookies: {
|
|
||||||
get(name: string) {
|
|
||||||
return request.cookies.get(name)?.value;
|
|
||||||
},
|
|
||||||
set(name: string, value: string, options: CookieOptions) {
|
|
||||||
// If the cookie is updated, update the cookies for the request and response
|
|
||||||
request.cookies.set({
|
|
||||||
name,
|
|
||||||
value,
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
response = NextResponse.next({
|
|
||||||
request: {
|
|
||||||
headers: request.headers,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
response.cookies.set({
|
|
||||||
name,
|
|
||||||
value,
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
remove(name: string, options: CookieOptions) {
|
|
||||||
// If the cookie is removed, update the cookies for the request and response
|
|
||||||
request.cookies.set({
|
|
||||||
name,
|
|
||||||
value: "",
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
response = NextResponse.next({
|
|
||||||
request: {
|
|
||||||
headers: request.headers,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
response.cookies.set({
|
|
||||||
name,
|
|
||||||
value: "",
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return { supabase, response };
|
|
||||||
};
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
import { createServerClient, type CookieOptions } from "@supabase/ssr";
|
|
||||||
import { cookies } from "next/headers";
|
|
||||||
|
|
||||||
export const createClient = (cookieStore: ReturnType<typeof cookies>) => {
|
|
||||||
return createServerClient(
|
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_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.
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user