Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: More CORS patches

Richie McIlroy0fba59268c8a
diff --git a/apps/desktop/src/components/windows/inner/Recorder.tsx b/apps/desktop/src/components/windows/inner/Recorder.tsx
index 2dc781df5..d5eaff086 100644
--- a/apps/desktop/src/components/windows/inner/Recorder.tsx
+++ b/apps/desktop/src/components/windows/inner/Recorder.tsx
@@ -83,6 +83,7 @@ export const Recorder = () => {
const res = await authFetch(
`${process.env.NEXT_PUBLIC_URL}/api/desktop/video/create`,
{
+ credentials: "include",
cache: "no-store",
headers: {
Authorization: `Bearer ${token}`,
diff --git a/apps/web/app/api/desktop/video/create/route.ts b/apps/web/app/api/desktop/video/create/route.ts
index 40da1e631..7b32ca050 100644
--- a/apps/web/app/api/desktop/video/create/route.ts
+++ b/apps/web/app/api/desktop/video/create/route.ts
@@ -1,19 +1,9 @@
-import { NextResponse, type NextRequest } from "next/server";
+import { type NextRequest } from "next/server";
import { db } from "@cap/database";
import { videos } from "@cap/database/schema";
import { getCurrentUser } from "@cap/database/auth/session";
import { nanoId } from "@cap/database/helpers";
-const corsHeaders = {
- "Access-Control-Allow-Origin": "*",
- "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
- "Access-Control-Allow-Headers": "Content-Type, Authorization",
-};
-
-export async function OPTIONS(req: NextRequest) {
- return NextResponse.json({}, { headers: corsHeaders });
-}
-
export async function GET(req: NextRequest) {
const user = await getCurrentUser();
const awsRegion = process.env.CAP_AWS_REGION;
@@ -24,7 +14,6 @@ export async function GET(req: NextRequest) {
status: 401,
headers: {
"Content-Type": "application/json",
- ...corsHeaders,
},
});
}
@@ -38,7 +27,7 @@ export async function GET(req: NextRequest) {
awsBucket: awsBucket,
});
- return new NextResponse(
+ return new Response(
JSON.stringify({
id: id,
user_id: user.userId,
@@ -49,7 +38,6 @@ export async function GET(req: NextRequest) {
status: 200,
headers: {
"Content-Type": "application/json",
- ...corsHeaders,
},
}
);
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs
index 0ed0c0d5d..3542bf459 100644
--- a/apps/web/next.config.mjs
+++ b/apps/web/next.config.mjs
@@ -123,7 +123,7 @@ const nextConfig = {
headers: [
{
key: "Access-Control-Allow-Origin",
- value: "tauri://localhost/",
+ value: "tauri://localhost",
},
{
key: "Access-Control-Allow-Methods",