Removed some of the calls to process.env; Used server props instead

This commit is contained in:
Andrew Pennington 2024-08-15 22:25:00 +01:00
parent 376220b26e
commit f51f36a411
No known key found for this signature in database
GPG key ID: E9DA097213FD17EA
5 changed files with 52 additions and 11 deletions

View file

@ -1,7 +1,31 @@
import ChatWindow from '@/components/ChatWindow';
import { FC } from 'react';
import process from 'process';
import { GetServerSideProps } from 'next';
const Page = ({ params }: { params: { chatId: string } }) => {
return <ChatWindow id={params.chatId} />;
interface PageProps {
backendApiUrl: string;
params: {
chatId: string;
};
}
export async function getServerSideProps(context): GetServerSideProps<PageProps> {
const backendApiUrl = process.env.BACKEND_API_URL;
const { chatId } = context.params || {};
return {
props: {
backendApiUrl,
params: {
chatId: chatId || '',
},
},
};
}
const Page: FC<PageProps> = ({ params, backendApiUrl }) => {
return <ChatWindow id={params.chatId} backendApiUrl={backendApiUrl} />;
};
export default Page;