diff --git a/.env.example b/.env.example
index 67f39f7fbd..098f3f62db 100644
--- a/.env.example
+++ b/.env.example
@@ -4,17 +4,9 @@ OPENAI_API_KEY=XXXXXXXX
# Generate a random secret: https://generate-secret.vercel.app/32 or `openssl rand -base64 32`
AUTH_SECRET=XXXXXXXX
-# Create a GitHub OAuth app here: https://github.com/settings/applications/new
-# For info on authorization callback URL visit here: https://authjs.dev/reference/core/providers_github#callback-url
-AUTH_GITHUB_ID=XXXXXXXX
-AUTH_GITHUB_SECRET=XXXXXXXX
-# Support OAuth login on preview deployments, see: https://authjs.dev/guides/basics/deployment#securing-a-preview-deployment
-# Set the following only when deployed. In this example, we can reuse the same OAuth app, but if you are storing users, we recommend using a different OAuth app for development/production so that you don't mix your test and production user base.
-# AUTH_REDIRECT_PROXY_URL=https://YOURAPP.vercel.app/api/auth
# Instructions to create kv database here: https://vercel.com/docs/storage/vercel-kv/quickstart and
KV_URL=XXXXXXXX
KV_REST_API_URL=XXXXXXXX
KV_REST_API_TOKEN=XXXXXXXX
-KV_REST_API_READ_ONLY_TOKEN=XXXXXXXX
-
+KV_REST_API_READ_ONLY_TOKEN=XXXXXXXX
\ No newline at end of file
diff --git a/README.md b/README.md
index 9884fa3692..79a6701071 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ This template ships with OpenAI `gpt-3.5-turbo` as the default. However, thanks
You can deploy your own version of the Next.js AI Chatbot to Vercel with one click:
-[](https://vercel.com/new/clone?demo-title=Next.js+Chat&demo-description=A+full-featured%2C+hackable+Next.js+AI+chatbot+built+by+Vercel+Labs&demo-url=https%3A%2F%2Fchat.vercel.ai%2F&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F4aVPvWuTmBvzM5cEdRdqeW%2F4234f9baf160f68ffb385a43c3527645%2FCleanShot_2023-06-16_at_17.09.21.png&project-name=Next.js+Chat&repository-name=nextjs-chat&repository-url=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-chatbot&from=templates&skippable-integrations=1&env=OPENAI_API_KEY%2CAUTH_GITHUB_ID%2CAUTH_GITHUB_SECRET%2CAUTH_SECRET&envDescription=How+to+get+these+env+vars&envLink=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-chatbot%2Fblob%2Fmain%2F.env.example&teamCreateStatus=hidden&stores=[{"type":"kv"}])
+[](https://vercel.com/new/clone?demo-title=Next.js+Chat&demo-description=A+full-featured%2C+hackable+Next.js+AI+chatbot+built+by+Vercel+Labs&demo-url=https%3A%2F%2Fchat.vercel.ai%2F&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F4aVPvWuTmBvzM5cEdRdqeW%2F4234f9baf160f68ffb385a43c3527645%2FCleanShot_2023-06-16_at_17.09.21.png&project-name=Next.js+Chat&repository-name=nextjs-chat&repository-url=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-chatbot&from=templates&skippable-integrations=1&env=OPENAI_API_KEY%2CAUTH_SECRET&envDescription=How+to+get+these+env+vars&envLink=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-chatbot%2Fblob%2Fmain%2F.env.example&teamCreateStatus=hidden&stores=[{"type":"kv"}])
## Creating a KV Database Instance
diff --git a/app/(chat)/chat/[id]/page.tsx b/app/(chat)/chat/[id]/page.tsx
index 0ca46b1398..c8de380442 100644
--- a/app/(chat)/chat/[id]/page.tsx
+++ b/app/(chat)/chat/[id]/page.tsx
@@ -2,8 +2,10 @@ import { type Metadata } from 'next'
import { notFound, redirect } from 'next/navigation'
import { auth } from '@/auth'
-import { getChat } from '@/app/actions'
+import { getChat, getMissingKeys } from '@/app/actions'
import { Chat } from '@/components/chat'
+import { AI } from '@/lib/chat/actions'
+import { Session } from '@/lib/types'
export interface ChatPageProps {
params: {
@@ -27,21 +29,32 @@ export async function generateMetadata({
}
export default async function ChatPage({ params }: ChatPageProps) {
- const session = await auth()
+ const session = (await auth()) as Session
+ const missingKeys = await getMissingKeys()
if (!session?.user) {
- redirect(`/sign-in?next=/chat/${params.id}`)
+ redirect(`/login?next=/chat/${params.id}`)
}
- const chat = await getChat(params.id, session.user.id)
+ const userId = session.user.id as string
+ const chat = await getChat(params.id, userId)
if (!chat) {
- notFound()
+ redirect('/')
}
if (chat?.userId !== session?.user?.id) {
notFound()
}
- return