if (!pathname.startsWith("/api")) {
try {
const { data } = await betterFetch<Session>("/api/auth/get-session", {
baseURL: req.nextUrl.origin,
headers: {
cookie: req.headers.get("cookie") || "",
},
});
session = data;
} catch (error) {
console.error("Error fetching session:", error);
}
}
if (!pathname.startsWith("/api")) {
try {
const { data } = await betterFetch<Session>("/api/auth/get-session", {
baseURL: req.nextUrl.origin,
headers: {
cookie: req.headers.get("cookie") || "",
},
});
session = data;
} catch (error) {
console.error("Error fetching session:", error);
}
}