Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Remove redirect of all dynamic pages to 404 and add dynamic page for displaying stream

Vasek Mlejnsky008ed962a5e8
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs
index b957ad55d..409555986 100644
--- a/apps/web/next.config.mjs
+++ b/apps/web/next.config.mjs
@@ -61,7 +61,6 @@ const nextConfig = {
destination: 'https://app.posthog.com/:path*',
// BEWARE: setting basePath will break the analytics proxy
},
- { source: '/:path*', destination: '/_404/:path*' },
]
}
}
diff --git a/apps/web/src/app/api/stream/sandbox/route.ts b/apps/web/src/app/api/stream/sandbox/route.ts
index 999c7b30b..af875e079 100644
--- a/apps/web/src/app/api/stream/sandbox/route.ts
+++ b/apps/web/src/app/api/stream/sandbox/route.ts
@@ -44,24 +44,3 @@ export async function POST(request: Request) {
return NextResponse.json({ streamKey: liveStream.stream_key }, { status: 201 })
}
-
-export async function GET(request: Request) {
- const url = new URL(request.url)
- const sandboxId = url.searchParams.get('sandboxId')
-
- if (!sandboxId) {
- return NextResponse.json({ error: 'Missing sandboxId' }, { status: 400 })
- }
-
- const { data, error } = await supabase
- .from('sandbox_streams')
- .select('playback_id')
- .eq('sandbox_id', sandboxId)
- .single()
-
- if (error || !data) {
- return NextResponse.json({ error: 'Playback ID not found' }, { status: 404 })
- }
-
- return NextResponse.json({ playbackId: data.playback_id }, { status: 200 })
-}
diff --git a/apps/web/src/app/stream/sandbox/[sandboxId]/page.tsx b/apps/web/src/app/stream/sandbox/[sandboxId]/page.tsx
new file mode 100644
index 000000000..1cb0e80a0
--- /dev/null
+++ b/apps/web/src/app/stream/sandbox/[sandboxId]/page.tsx
@@ -0,0 +1,51 @@
+import { Suspense } from 'react'
+import { createClient } from '@supabase/supabase-js'
+import MuxPlayer from '@mux/mux-player-react'
+
+const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!
+const supabaseServiceKey = process.env.SUPABASE_SERVICE_ROLE_KEY!
+
+const supabase = createClient(supabaseUrl, supabaseServiceKey)
+
+interface SandboxStream {
+ sandboxId: string
+ playbackId: string
+}
+
+async function fetchStream(sandboxId: string): Promise<SandboxStream | null> {
+ const { data, error } = await supabase
+ .from('sandbox_streams')
+ .select('playback_id')
+ .eq('sandbox_id', sandboxId)
+ .single()
+
+ if (error || !data) {
+ return null
+ }
+
+ return { sandboxId, playbackId: data.playback_id }
+}
+
+export default async function StreamPage({ params }: { params: { sandboxId: string } }) {
+ const stream = await fetchStream(params.sandboxId)
+
+ if (!stream) {
+ return <div>Stream not found</div>
+ }
+
+ return (
+ <Suspense fallback={<div>Loading...</div>}>
+ <h1>Stream Details</h1>
+ <div>Sandbox ID: {stream.sandboxId}</div>
+ <div>Playback ID: {stream.playbackId}</div>
+
+ <MuxPlayer
+ playbackId={stream.playbackId}
+ metadata={{
+ video_id: `sandbox-${stream.sandboxId}`,
+ video_title: 'Desktop Sandbox Stream',
+ }}
+ />
+ </Suspense>
+ )
+}
diff --git a/apps/web/src/app/stream/sandbox/page.tsx b/apps/web/src/app/stream/sandbox/page.tsx
deleted file mode 100644
index ebe11f966..000000000
--- a/apps/web/src/app/stream/sandbox/page.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-'use client'
-
-import { useSearchParams } from 'next/navigation'
-import { useEffect, useState, Suspense } from 'react'
-// @ts-ignore
-import MuxPlayer from '@mux/mux-player-react'
-
-
-
-interface SandboxStream {
- sandboxId: string
- playbackId: string
-}
-
-export default function StreamPage() {
- const searchParams = useSearchParams()
- const sandboxId = searchParams.get('sandboxId')
- const [stream, setStream] = useState<SandboxStream | null>(null)
- const [error, setError] = useState<string | null>(null)
-
- useEffect(() => {
- const fetchStream = async () => {
- if (sandboxId) {
- try {
- const response = await fetch(`/api/stream/sandbox?sandboxId=${sandboxId}`)
- if (!response.ok) {
- throw new Error('Network response was not ok')
- }
- const data = await response.json()
- setStream(data)
- } catch (err) {
- setError(err.message)
- }
- }
- }
-
- fetchStream()
- }, [sandboxId])
-
- if (error) {
- return <div>Error loading stream: {error}</div>
- }
-
- if (!stream) {
- return <div>Stream not found</div>
- }
- console.log('stream', stream)
-
- return (
- <Suspense fallback={<div>Loading...</div>}>
- hello
- <h1>Stream Details</h1>
- <div>Sandbox ID: {stream.sandboxId}</div>
- <div>Playback ID: {stream.playbackId}</div>
-
- <MuxPlayer
- playbackId={stream.playbackId}
- metadata={{
- video_id: 'video-id-54321',
- video_title: 'Test video title',
- viewer_user_id: 'user-id-007',
- }}
- />
- </Suspense>
- )
-}
\ No newline at end of file
diff --git a/apps/web/src/types/mux-player-react.d.ts b/apps/web/src/types/mux-player-react.d.ts
new file mode 100644
index 000000000..7c5d47e17
--- /dev/null
+++ b/apps/web/src/types/mux-player-react.d.ts
@@ -0,0 +1,9 @@
+declare module '@mux/mux-player-react' {
+ export interface MuxPlayerProps {
+ [key: string]: any;
+ playbackId: string;
+ metadata?: Record<string, any>;
+ }
+
+ export default function MuxPlayer(props: MuxPlayerProps): JSX.Element
+}
\ No newline at end of file