demo: fix deployment

This commit is contained in:
Bereket Engida
2024-10-26 22:13:29 +03:00
parent d706c6f1e6
commit 1d577e7faf
4 changed files with 1285 additions and 87 deletions

View File

@@ -1,15 +1,18 @@
import { client } from "@/lib/auth-client";
import { betterFetch } from "@better-fetch/fetch";
import { NextRequest, NextResponse } from "next/server";
import type { Session } from "./lib/auth-types";
export default async function authMiddleware(request: NextRequest) {
const { data: 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) {
return NextResponse.redirect(new URL("/", request.url));