forked from supabase/supabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(docs): move last pages over to app router (supabase#29293)
The end of the Great Migration is here!!! Moves the last pages over, deleting pages like the FAQ that we don't use and that contain duplicated information anyway. Dev secret auth page URL had to change as App Router doesn't like the leading underscores in the path. Also fixes the not-found recommendations to use the proper Next.js not-found page so it will return a 404 as it should. (I was under the erroneous impression that I couldn't get the pathname in not-found.tsx, that is not true, so this works better.)
- Loading branch information
Showing
23 changed files
with
191 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { SupabaseClient } from '@supabase/supabase-js' | ||
import { ApplicationError, UserError, clippy } from 'ai-commands/edge' | ||
import { NextRequest, NextResponse } from 'next/server' | ||
import OpenAI from 'openai' | ||
|
||
export const runtime = 'edge' | ||
/* To avoid OpenAI errors, restrict to the Vercel Edge Function regions that | ||
overlap with the OpenAI API regions. | ||
Reference for Vercel regions: https://vercel.com/docs/edge-network/regions#region-list | ||
Reference for OpenAI regions: https://help.openai.com/en/articles/5347006-openai-api-supported-countries-and-territories | ||
*/ | ||
export const preferredRegion = [ | ||
'arn1', | ||
'bom1', | ||
'cdg1', | ||
'cle1', | ||
'cpt1', | ||
'dub1', | ||
'fra1', | ||
'gru1', | ||
'hnd1', | ||
'iad1', | ||
'icn1', | ||
'kix1', | ||
'lhr1', | ||
'pdx1', | ||
'sfo1', | ||
'sin1', | ||
'syd1', | ||
] | ||
|
||
const openAiKey = process.env.OPENAI_API_KEY | ||
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL as string | ||
const supabaseServiceKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY as string | ||
|
||
export async function POST(req: NextRequest) { | ||
if (!openAiKey || !supabaseUrl || !supabaseServiceKey) { | ||
return NextResponse.json( | ||
{ error: 'Missing environment variables for AI features.' }, | ||
{ status: 500 } | ||
) | ||
} | ||
|
||
const openai = new OpenAI({ apiKey: openAiKey }) | ||
const supabaseClient = new SupabaseClient(supabaseUrl, supabaseServiceKey) | ||
|
||
try { | ||
const { messages } = (await req.json()) as { | ||
messages: { content: string; role: 'user' | 'assistant' }[] | ||
} | ||
|
||
if (!messages) { | ||
throw new UserError('Missing messages in request data') | ||
} | ||
|
||
const response = await clippy(openai, supabaseClient, messages) | ||
|
||
// Proxy the streamed SSE response from OpenAI | ||
return new NextResponse(response.body, { | ||
headers: { | ||
'Content-Type': 'text/event-stream', | ||
}, | ||
}) | ||
} catch (error: unknown) { | ||
console.error(error) | ||
if (error instanceof UserError) { | ||
return NextResponse.json({ error: error.message, data: error.data }, { status: 400 }) | ||
} else if (error instanceof ApplicationError) { | ||
console.error(`${error.message}: ${JSON.stringify(error.data)}`) | ||
} else { | ||
console.error(error) | ||
} | ||
|
||
return NextResponse.json( | ||
{ error: 'There was an error processing your request' }, | ||
{ status: 500 } | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { notFound } from 'next/navigation' | ||
|
||
import { DevSecretAuthForm } from './AuthForm.client' | ||
|
||
export default async function DevOnlySecretAuth() { | ||
if (process.env.NEXT_PUBLIC_DEV_AUTH_PAGE !== 'true') { | ||
throw notFound() | ||
} | ||
|
||
return <DevSecretAuthForm /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { type Metadata } from 'next' | ||
import Link from 'next/link' | ||
|
||
import { Button } from 'ui' | ||
|
||
import { Recommendations, SearchButton } from '~/features/recommendations/NotFound.client' | ||
import { LayoutMainContent } from '~/layouts/DefaultLayout' | ||
import { SidebarSkeleton } from '~/layouts/MainSkeleton' | ||
|
||
export default function NotFound() { | ||
return ( | ||
<SidebarSkeleton> | ||
<LayoutMainContent> | ||
<article className="prose max-w-[80ch]"> | ||
<h1>404: We couldn't find that page</h1> | ||
<p> | ||
Sorry, we couldn't find that page. It might be missing, or we had a temporary error | ||
generating it. | ||
</p> | ||
<div className="flex flex-wrap gap-4 pt-4"> | ||
<SearchButton /> | ||
<Button type="default" size="small" className="p-4" asChild> | ||
<Link href="/" className="no-underline"> | ||
Return to homepage | ||
</Link> | ||
</Button> | ||
<Button type="text" size="small" asChild> | ||
<Link | ||
href="https://github.com/supabase/supabase/issues/new?assignees=&labels=documentation&projects=&template=2.Improve_docs.md" | ||
target="_blank" | ||
rel="noreferrer noopener" | ||
className="no-underline" | ||
> | ||
Report missing page | ||
</Link> | ||
</Button> | ||
</div> | ||
<Recommendations /> | ||
</article> | ||
</LayoutMainContent> | ||
</SidebarSkeleton> | ||
) | ||
} | ||
|
||
export const metadata: Metadata = { | ||
title: 'Not found', | ||
robots: { | ||
index: false, | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.