From 15e862533d73323077969648c603cc3be7d1d6ec Mon Sep 17 00:00:00 2001 From: Jonas Schell Date: Thu, 22 Aug 2024 11:43:48 +0200 Subject: [PATCH] cloudflare config --- app/api/record/start/route.ts | 2 ++ app/api/record/stop/route.ts | 2 ++ app/api/token/route.ts | 2 ++ app/api/url/route.ts | 2 ++ app/custom/page.tsx | 2 ++ app/page.tsx | 2 ++ app/rooms/[roomName]/page.tsx | 2 ++ next.config.js => next.config.mjs | 10 +++++++++- 8 files changed, 23 insertions(+), 1 deletion(-) rename next.config.js => next.config.mjs (58%) diff --git a/app/api/record/start/route.ts b/app/api/record/start/route.ts index a07f381..a168e0b 100644 --- a/app/api/record/start/route.ts +++ b/app/api/record/start/route.ts @@ -1,6 +1,8 @@ import { EgressClient, EncodedFileOutput, S3Upload } from 'livekit-server-sdk'; import { NextResponse } from 'next/server'; +export const runtime = 'edge'; + export async function GET(req: Request) { try { const url = new URL(req.url); diff --git a/app/api/record/stop/route.ts b/app/api/record/stop/route.ts index bfbfc49..b4cf39f 100644 --- a/app/api/record/stop/route.ts +++ b/app/api/record/stop/route.ts @@ -1,6 +1,8 @@ import { EgressClient } from 'livekit-server-sdk'; import { NextResponse } from 'next/server'; +export const runtime = 'edge'; + export async function GET(req: Request) { try { const url = new URL(req.url); diff --git a/app/api/token/route.ts b/app/api/token/route.ts index 3503839..60ff538 100644 --- a/app/api/token/route.ts +++ b/app/api/token/route.ts @@ -3,6 +3,8 @@ import type { AccessTokenOptions, VideoGrant } from 'livekit-server-sdk'; import { TokenResult } from '@/lib/types'; import { NextResponse } from 'next/server'; +export const runtime = 'edge'; + const apiKey = process.env.LIVEKIT_API_KEY; const apiSecret = process.env.LIVEKIT_API_SECRET; diff --git a/app/api/url/route.ts b/app/api/url/route.ts index c6c9426..1b80308 100644 --- a/app/api/url/route.ts +++ b/app/api/url/route.ts @@ -1,6 +1,8 @@ import { getLiveKitURL } from '../../../lib/server-utils'; import { NextResponse } from 'next/server'; +export const runtime = 'edge'; + export async function GET(req: Request) { try { const url = new URL(req.url); diff --git a/app/custom/page.tsx b/app/custom/page.tsx index c7d5a78..3c8d9dd 100644 --- a/app/custom/page.tsx +++ b/app/custom/page.tsx @@ -2,6 +2,8 @@ import { videoCodecs } from 'livekit-client'; import { VideoConferenceClientImpl } from './VideoConferenceClientImpl'; import { isVideoCodec } from '@/lib/types'; +export const runtime = 'edge'; + export default function CustomRoomConnection(props: { searchParams: { liveKitUrl?: string; diff --git a/app/page.tsx b/app/page.tsx index d23d536..ba10abf 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -5,6 +5,8 @@ import React, { Suspense, useState } from 'react'; import { encodePassphrase, generateRoomId, randomString } from '@/lib/client-utils'; import styles from '../styles/Home.module.css'; +export const runtime = 'edge'; + function Tabs(props: React.PropsWithChildren<{}>) { const searchParams = useSearchParams(); const tabIndex = searchParams?.get('tab') === 'custom' ? 1 : 0; diff --git a/app/rooms/[roomName]/page.tsx b/app/rooms/[roomName]/page.tsx index 70876d4..7fd4bb7 100644 --- a/app/rooms/[roomName]/page.tsx +++ b/app/rooms/[roomName]/page.tsx @@ -27,6 +27,8 @@ import { SettingsMenu } from '@/lib/SettingsMenu'; import { RecordingIndicator } from '@/lib/RecordingIndicator'; import { isVideoCodec } from '@/lib/types'; +export const runtime = 'edge'; + export default function Page({ params }: { params: { roomName: string } }) { const router = useRouter(); const roomName = params.roomName; diff --git a/next.config.js b/next.config.mjs similarity index 58% rename from next.config.js rename to next.config.mjs index 76f094f..f999f6b 100644 --- a/next.config.js +++ b/next.config.mjs @@ -1,3 +1,5 @@ +import { setupDevPlatform } from '@cloudflare/next-on-pages/next-dev'; + /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: false, @@ -13,4 +15,10 @@ const nextConfig = { }, }; -module.exports = nextConfig; +// This allows you to access Cloudflare bindings in local development. +// Ignore this, you probably don't need it. +if (process.env.NODE_ENV === 'development') { + await setupDevPlatform(); +} + +export default nextConfig;