Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix hot reload on dev mode

Tomas Valenta6f8f5cf34c1b
diff --git a/.env.example b/.env.example
index e7cb8bd70..435ca0986 100644
--- a/.env.example
+++ b/.env.example
@@ -1,10 +1,7 @@
-# OpenAI
-OPENAI_API_KEY=
-
# Supabase
# URL for the Supabase DB.
# The preconfigured value with localhost is for the development with local Supabase.
-SUPABASE_URL=http://localhost:54321
+NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321
# Postgres connection string for the Supabase DB used by Prisma.
# The preconfigured value with localhost is for the development with local Supabase.
@@ -21,4 +18,4 @@ NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzd
# e2b API
# URL for the e2b API
-API_URL=http://localhost:49155
+NEXT_PUBLIC_API_URL=http://localhost:49155
diff --git a/Dockerfile b/Dockerfile
index f9e984fc4..36cbcfe13 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -11,6 +11,13 @@ COPY . .
ARG NEXT_PUBLIC_SIGN_IN_EMAIL
ARG NEXT_PUBLIC_SIGN_IN_PASSWORD
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
+ARG NEXT_PUBLIC_SUPABASE_URL
+ARG NEXT_PUBLIC_PROXY
+ARG NEXT_PUBLIC_API_URL
+
+ENV NEXT_PUBLIC_PROXY=$NEXT_PUBLIC_PROXY
+ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
+ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
ENV NEXT_TELEMETRY_DISABLED 1
ENV BUILD docker
diff --git a/api-service/playground/src/data/logOutput.ts b/api-service/playground/src/data/logOutput.ts
index b6f704b27..426e6b5ff 100644
--- a/api-service/playground/src/data/logOutput.ts
+++ b/api-service/playground/src/data/logOutput.ts
@@ -9,7 +9,7 @@ dotenv.config({
path: '../../.env',
})
-const client = createClient<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_ROLE_KEY!)
+const client = createClient<Database>(process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.SUPABASE_SERVICE_ROLE_KEY!)
export const projectsTable = 'projects'
export const deploymentsTable = 'deployments'
diff --git a/components/Editor/Sidebar/index.tsx b/components/Editor/Sidebar/index.tsx
index 7ff005e72..57026b0d9 100644
--- a/components/Editor/Sidebar/index.tsx
+++ b/components/Editor/Sidebar/index.tsx
@@ -68,6 +68,10 @@ async function handlePostGenerate(url: string, { arg }: {
}).then(r => r.json())
}
+const apiURL = process.env.NEXT_PUBLIC_PROXY
+ ? '/api/service'
+ : process.env.NEXT_PUBLIC_API_URL
+
function Sidebar({
project,
route,
@@ -78,7 +82,7 @@ function Sidebar({
const {
trigger: generate,
isMutating: isDeployRequestRunning,
- } = useSWRMutation('/api/service/generate', handlePostGenerate)
+ } = useSWRMutation(`${apiURL}/generate`, handlePostGenerate)
const [selectors] = useStateStore()
const envs = selectors.use.envs()
diff --git a/db/credentials.ts b/db/credentials.ts
index ab674c9e7..538dcd95f 100644
--- a/db/credentials.ts
+++ b/db/credentials.ts
@@ -1,13 +1,15 @@
export const serverCreds = {
- supabaseUrl: process.env.SUPABASE_URL,
+ supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL,
supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY,
}
-const baseURL = typeof window !== 'undefined'
- && `${window.location.protocol}//${window.location.host}`
+const supabaseURL = typeof window !== 'undefined'
+ ? `${window.location.protocol}//${window.location.host}`
+ : 'http://localhost:3000'
-// 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` : 'http://localhost:3000/api/supabase',
+ supabaseUrl: process.env.NEXT_PUBLIC_PROXY
+ ? `${supabaseURL}/api/supabase`
+ : process.env.NEXT_PUBLIC_SUPABASE_URL,
supabaseKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
}
diff --git a/docker-compose.yml b/docker-compose.yml
index b6f1ca088..78450a3c1 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -7,7 +7,7 @@ services:
context: ./api-service
environment:
- PORT=49155
- - SUPABASE_URL=http://supabase_kong_workspace:8000
+ - NEXT_PUBLIC_SUPABASE_URL=http://supabase_kong_workspace:8000
# The following default key is generated by the local Supabase start and doesn't change
- SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
expose:
@@ -23,6 +23,9 @@ services:
build:
context: ./
args:
+ NEXT_PUBLIC_SUPABASE_URL: http://supabase_kong_workspace:8000
+ NEXT_PUBLIC_API_URL: http://api:49155
+ NEXT_PUBLIC_PROXY: 1
NEXT_PUBLIC_SIGN_IN_EMAIL: [email protected]
NEXT_PUBLIC_SIGN_IN_PASSWORD: [email protected]
# The following default key is generated by the local Supabase start and doesn't change
@@ -32,8 +35,6 @@ services:
- supabase_db_workspace
environment:
- 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
# The following default key is generated by the local Supabase start and doesn't change
- SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
diff --git a/pages/api/service/[...all].ts b/pages/api/service/[...all].ts
index 8ddcc3f6e..171422d41 100644
--- a/pages/api/service/[...all].ts
+++ b/pages/api/service/[...all].ts
@@ -16,7 +16,7 @@ export const config = {
const pathPrefix = '/api/service'
-const target = process.env.API_URL!
+const target = process.env.NEXT_PUBLIC_API_URL!
const isSecure = target.startsWith('https://')
const proxy = createProxyMiddleware<NextApiRequest, NextApiResponse>({
diff --git a/pages/api/supabase/[...all].ts b/pages/api/supabase/[...all].ts
index 53371643e..daaa37796 100644
--- a/pages/api/supabase/[...all].ts
+++ b/pages/api/supabase/[...all].ts
@@ -15,7 +15,7 @@ export const config = {
const pathPrefix = '/api/supabase'
-const target = process.env.SUPABASE_URL!
+const target = process.env.NEXT_PUBLIC_SUPABASE_URL!
const isSecure = target.startsWith('https://')
const proxy = createProxyMiddleware<NextApiRequest, NextApiResponse>({