Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fix next build public env vars
Tomas Valentae6a64a0980aa
diff --git a/Dockerfile b/Dockerfileindex 0ef08a8a0..5cb3d2953 100644--- a/Dockerfile+++ b/Dockerfile@@ -8,6 +8,10 @@ RUN npm ciCOPY . .+ARG NEXT_PUBLIC_SIGN_IN_EMAIL+ARG NEXT_PUBLIC_SIGN_IN_PASSWORD+ARG NEXT_PUBLIC_SUPABASE_ANON_KEY+ENV NEXT_TELEMETRY_DISABLED 1ENV BUILD dockerRUN npm run build@@ -16,6 +20,7 @@ RUN npm run buildFROM node:lts-slim AS runnerWORKDIR /app+ENV NODE_ENV productionENV NEXT_TELEMETRY_DISABLED 1ENV PORT 3000diff --git a/db/credentials.ts b/db/credentials.tsindex 821fff452..29f8d5345 100644--- a/db/credentials.ts+++ b/db/credentials.ts@@ -1,8 +1,13 @@+export const serverCreds = {+ supabaseUrl: process.env.SUPABASE_URL,+ supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY,+}+const baseURL = typeof window !== 'undefined'- ? `${window.location.protocol}//${window.location.host}`- : '<THIS-SHOULD-BE-URL>'+ && `${window.location.protocol}//${window.location.host}`-export const credentials = {- supabaseUrl: process.env.SUPABASE_URL || `${baseURL}/api/supabase`,- supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,+// The SUPABASE_URL is actually not used but we need a valid URL for the SSR render.+export const clientCreds = {+ supabaseUrl: baseURL ? `${baseURL}/api/supabase` : process.env.SUPABASE_URL,+ supabaseKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,}diff --git a/docker-compose.yml b/docker-compose.ymlindex 6440d4a1b..ef2c570e6 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -22,18 +22,19 @@ services:image: e2b/app-dev:latestbuild:context: ./+ args:+ NEXT_PUBLIC_SIGN_IN_EMAIL: [email protected]+ NEXT_PUBLIC_SIGN_IN_PASSWORD: [email protected]+ NEXT_PUBLIC_SUPABASE_ANON_KEY: ${NEXT_PUBLIC_SUPABASE_ANON_KEY}external_links:- supabase_kong_workspace- supabase_db_workspaceenvironment:- NODE_ENV=development- SUPABASE_URL=http://supabase_kong_workspace:8000- API_URL=http://api:49155- SUPABASE_POSTGRES_URL=postgresql://postgres:postgres@supabase_db_workspace:5432/postgres- SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY}- - NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY}ports:- 3000:3000networks:diff --git a/pages/[projectID].tsx b/pages/[projectID].tsxindex cb7faa03f..fd077fc63 100644--- a/pages/[projectID].tsx+++ b/pages/[projectID].tsx@@ -7,7 +7,7 @@ import { prisma, projects } from 'db/prisma'import Editor from 'components/Editor'import { StoreProvider } from 'state/StoreProvider'import { Database } from 'db/supabase'-import { credentials } from 'db/credentials'+import { serverCreds } from 'db/credentials'interface PathProps extends ParsedUrlQuery {projectID: string@@ -21,7 +21,7 @@ export const getServerSideProps: GetServerSideProps<Props, PathProps> = async (c}}- const supabase = createServerSupabaseClient(ctx, credentials)+ const supabase = createServerSupabaseClient(ctx, serverCreds)const {data: { session },} = await supabase.auth.getSession()diff --git a/pages/_app.tsx b/pages/_app.tsxindex bdc0b699b..6816f875f 100644--- a/pages/_app.tsx+++ b/pages/_app.tsx@@ -11,7 +11,7 @@ import 'styles/global.css'import Header from 'components/Header'import { Database } from 'db/supabase'-import { credentials } from 'db/credentials'+import { clientCreds } from 'db/credentials'const inter = Inter({subsets: ['latin'],@@ -20,7 +20,7 @@ const inter = Inter({function App({ Component, pageProps }: AppProps<{ initialSession: Session, project?: projects }>) {const router = useRouter()- const [supabaseClient] = useState(() => createBrowserSupabaseClient<Database>(credentials))+ const [supabaseClient] = useState(() => createBrowserSupabaseClient<Database>(clientCreds))const isSignIn = router.pathname === '/sign' && router.query.signup !== 'true'const isSignUp = router.pathname === '/sign' && router.query.signup === 'true'diff --git a/pages/api/project.ts b/pages/api/project.tsindex d1f3142d8..bc759b95b 100644--- a/pages/api/project.ts+++ b/pages/api/project.ts@@ -2,7 +2,7 @@ import { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs'import { NextApiRequest, NextApiResponse } from 'next'import { prisma } from 'db/prisma'-import { credentials } from 'db/credentials'+import { serverCreds } from 'db/credentials'export interface PostProjectBody {id: string@@ -14,7 +14,7 @@ async function postProject(req: NextApiRequest, res: NextApiResponse) {} = req.body as PostProjectBodytry {- const supabase = createServerSupabaseClient({ req, res }, credentials)+ const supabase = createServerSupabaseClient({ req, res }, serverCreds)const { data: { session } } = await supabase.auth.getSession()if (!session) {return res.status(401).json({@@ -75,7 +75,7 @@ async function deleteProject(req: NextApiRequest, res: NextApiResponse) {const { id } = req.body as PostProjectBodytry {- const supabase = createServerSupabaseClient({ req, res }, credentials)+ const supabase = createServerSupabaseClient({ req, res }, serverCreds)const { data: { session } } = await supabase.auth.getSession()if (!session) {return res.status(401).json({diff --git a/pages/index.tsx b/pages/index.tsxindex 63c465cd4..0157b7fb2 100644--- a/pages/index.tsx+++ b/pages/index.tsx@@ -8,10 +8,10 @@ import ItemList from 'components/ItemList'import Text from 'components/Text'import { prisma, projects } from 'db/prisma'import Button from 'components/Button'-import { credentials } from 'db/credentials'+import { serverCreds } from 'db/credentials'export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {- const supabase = createServerSupabaseClient(ctx, credentials)+ const supabase = createServerSupabaseClient(ctx, serverCreds)const {data: { session },} = await supabase.auth.getSession()diff --git a/pages/settings.tsx b/pages/settings.tsxindex 34cc57907..4519a78bf 100644--- a/pages/settings.tsx+++ b/pages/settings.tsx@@ -7,10 +7,10 @@ import { useSupabaseClient, useUser } from '@supabase/auth-helpers-react'import Button from 'components/Button'import Text from 'components/Text'import { Database } from 'db/supabase'-import { credentials } from 'db/credentials'+import { serverCreds } from 'db/credentials'export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {- const supabase = createServerSupabaseClient<Database>(ctx, credentials)+ const supabase = createServerSupabaseClient<Database>(ctx, serverCreds)const {data: { session },} = await supabase.auth.getSession()