bolt.new/packages/bolt/app/routes/_index.tsx

30 lines
993 B
TypeScript
Raw Normal View History

2024-07-11 19:25:19 +00:00
import { json, redirect, type LoaderFunctionArgs, type MetaFunction } from '@remix-run/cloudflare';
2024-07-10 16:44:39 +00:00
import { ClientOnly } from 'remix-utils/client-only';
import { BaseChat } from '../components/chat/BaseChat';
import { Chat } from '../components/chat/Chat.client';
import { Header } from '../components/Header';
import { isAuthenticated } from '../lib/.server/sessions';
2024-07-10 16:44:39 +00:00
export const meta: MetaFunction = () => {
return [{ title: 'Bolt' }, { name: 'description', content: 'Talk with Bolt, an AI assistant from StackBlitz' }];
};
2024-07-11 19:25:19 +00:00
export async function loader({ request, context }: LoaderFunctionArgs) {
const authenticated = await isAuthenticated(request, context.cloudflare.env);
if (import.meta.env.DEV || authenticated) {
return json({});
}
return redirect('/login');
}
2024-07-10 16:44:39 +00:00
export default function Index() {
return (
<div className="flex flex-col h-full w-full">
<Header />
<ClientOnly fallback={<BaseChat />}>{() => <Chat />}</ClientOnly>
</div>
);
}