Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: Add allowed origins
Richie McIlroy3489118829a8
diff --git a/apps/web/app/api/desktop/video/create/route.ts b/apps/web/app/api/desktop/video/create/route.tsindex 7b32ca050..40b4c2e4a 100644--- a/apps/web/app/api/desktop/video/create/route.ts+++ b/apps/web/app/api/desktop/video/create/route.ts@@ -4,16 +4,46 @@ import { videos } from "@cap/database/schema";import { getCurrentUser } from "@cap/database/auth/session";import { nanoId } from "@cap/database/helpers";+const allowedOrigins = [+ process.env.NEXT_PUBLIC_URL,+ "http://localhost:3001",+ "tauri://localhost",+ "http://tauri.localhost",+];++export async function OPTIONS(req: NextRequest) {+ const origin = req.nextUrl.origin;++ return new Response(null, {+ status: 200,+ headers: {+ "Access-Control-Allow-Origin": allowedOrigins.includes(origin)+ ? origin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ "Access-Control-Allow-Methods": "GET, OPTIONS",+ "Access-Control-Allow-Headers": "Authorization",+ },+ });+}+export async function GET(req: NextRequest) {const user = await getCurrentUser();const awsRegion = process.env.CAP_AWS_REGION;const awsBucket = process.env.CAP_AWS_BUCKET;+ const origin = req.nextUrl.origin;if (!user) {return new Response(JSON.stringify({ error: true }), {status: 401,headers: {"Content-Type": "application/json",+ "Access-Control-Allow-Origin": allowedOrigins.includes(origin)+ ? origin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ "Access-Control-Allow-Methods": "GET, OPTIONS",+ "Access-Control-Allow-Headers": "Authorization",},});}@@ -38,6 +68,12 @@ export async function GET(req: NextRequest) {status: 200,headers: {"Content-Type": "application/json",+ "Access-Control-Allow-Origin": allowedOrigins.includes(origin)+ ? origin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ "Access-Control-Allow-Methods": "GET, OPTIONS",+ "Access-Control-Allow-Headers": "Authorization",},});