fix: update user reverting default fields

This commit is contained in:
Bereket Engida
2024-10-27 10:40:50 +03:00
parent b36c03f83d
commit 44ab168d27
7 changed files with 1255 additions and 1170 deletions

View File

@@ -1,26 +1,20 @@
import { betterFetch } from "@better-fetch/fetch";
import { NextRequest, NextResponse } from "next/server";
import { client } from "./lib/auth-client";
import type { Session } from "./lib/auth-types";
export async function middleware(request: NextRequest) {
// const { data: session } = await betterFetch<Session>(
// "/api/auth/get-session",
// {
// baseURL: request.nextUrl.origin,
// headers: {
// //get the cookie from the request
// cookie: request.headers.get("cookie") || "",
// },
// },
// );
const session = await client.getSession({
fetchOptions: {
const { data: session } = await betterFetch<Session>(
"/api/auth/get-session",
{
baseURL: request.nextUrl.origin,
headers: {
//get the cookie from the request
cookie: request.headers.get("cookie") || "",
},
},
});
);
if (!session.data) {
if (!session) {
return NextResponse.redirect(new URL("/", request.url));
}
return NextResponse.next();