// \frontend\src\app\chat\[...slug]\page.jsx
import { notFound, redirect } from "next/navigation";
import mongoDbCreateUser from "@/lib/mongoDbCreateUser";
import ChatWrapper from "@/app/chat/[...slug]/ChatWrapper";
import { auth0 } from "@/lib/auth0";
export async function generateMetadata({ params, searchParams }) {
const { slug } = await params;
const searchParamsTemp = await searchParams;
const initialMessage = searchParamsTemp?.q;
return {
metadataBase: new URL(process.env.NEXT_PUBLIC_SITE_URL ?? "http://localhost:3000"),
title: `Chat | ${slug ? "Session" : initialMessage ? "New Session" : "bureaucrazy.co"}`,
icons: {
icon: "/web/Logo.webp",
shortcut: "/web/Logo.webp",
apple: "/web/Logo.webp",
},
robots: {
index: false,
follow: false,
nocache: true,
},
openGraph: {
title: "bureaucrazy.co",
description: "",
url: "https://www.bureaucrazy.co/",
siteName: "bureaucrazy.co",
images: [
{
url: "/web/Logo.webp",
width: 1200,
height: 630,
alt: "Bureaucrazy logo",
},
],
locale: "en_US",
type: "website",
},
};
}
export default async function Page({ params, searchParams }) {
const { slug } = await params;
const searchParamsTemp = await searchParams;
const initialMessage = searchParamsTemp.q;
const { getUserInfo } = await mongoDbCreateUser();
const session = await auth0.getSession();
if (!session) {
redirect(`/chat/testing/?q=${initialMessage || "Hi bureaucrazy!"}`);
}
const chatSession = getUserInfo.sessions.find((data) => data.sessionId == slug);
if (chatSession) {
return (
<>
<main className=" w-full flex flex-1 relative flex-col justify-between ">
<ChatWrapper session={session} initialMsg={chatSession} />
</main>
</>
);
}
if (!chatSession && initialMessage) {
return (
<>
<main className=" w-full flex flex-1 relative flex-col justify-between ">
<ChatWrapper session={session} initialMsg={decodeURIComponent(initialMessage)} />
</main>
</>
);
} else {
return (
<>
<main className=" w-full flex flex-1 relative flex-col justify-between ">{notFound()}</main>
</>
);
}
}
Access to fetch at 'https://auth.bureaucrazy.co/authorize?client_id=..y.co' (redirected from 'https://www.bureaucrazy.co/auth/login?_rsc=tgark') from origin 'https://www.bureaucrazy.co' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Failed to load resource: net::ERR_FAILED
1255-f206d8cb7c37a3ff.js:1 Failed to fetch RSC payload for https://www.bureaucrazy.co/auth/login. Falling back to browser navigation.
I have tried out everything
I can log in successfully, but I get logged out when I refresh the page or navigate to another dynamic route.