Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: add more CORS

Richie McIlroydf2a9ef3d107
diff --git a/apps/web/app/api/desktop/video/create/route.ts b/apps/web/app/api/desktop/video/create/route.ts
index e5e74d793..7b32ca050 100644
--- a/apps/web/app/api/desktop/video/create/route.ts
+++ b/apps/web/app/api/desktop/video/create/route.ts
@@ -9,23 +9,11 @@ export async function GET(req: NextRequest) {
const awsRegion = process.env.CAP_AWS_REGION;
const awsBucket = process.env.CAP_AWS_BUCKET;
- const allowedOrigins = [
- process.env.NEXT_PUBLIC_URL,
- "tauri://localhost",
- "http://localhost:3001",
- ];
- const requestOrigin = req.headers.get("origin") || "";
- const allowedOrigin = allowedOrigins.includes(requestOrigin)
- ? requestOrigin
- : false;
-
if (!user) {
return new Response(JSON.stringify({ error: true }), {
status: 401,
headers: {
"Content-Type": "application/json",
- ...(allowedOrigin && { "Access-Control-Allow-Origin": allowedOrigin }),
- "Access-Control-Allow-Credentials": "true",
},
});
}
@@ -50,8 +38,6 @@ export async function GET(req: NextRequest) {
status: 200,
headers: {
"Content-Type": "application/json",
- ...(allowedOrigin && { "Access-Control-Allow-Origin": allowedOrigin }),
- "Access-Control-Allow-Credentials": "true",
},
}
);
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs
index a4bb34d20..eadaeeac1 100644
--- a/apps/web/next.config.mjs
+++ b/apps/web/next.config.mjs
@@ -81,7 +81,48 @@ const nextConfig = {
headers: [
{
key: "Access-Control-Allow-Origin",
- value: "tauri://localhost",
+ value: "https://tauri.localhost",
+ },
+ {
+ key: "Access-Control-Allow-Methods",
+ value: "GET, POST, PUT, DELETE, OPTIONS",
+ },
+ {
+ key: "Access-Control-Allow-Headers",
+ value: "Content-Type, Authorization",
+ },
+ {
+ key: "Access-Control-Allow-Credentials",
+ value: "true",
+ },
+ ],
+ {
+ source: "/api/desktop/(.*)",
+ headers: [
+ {
+ key: "Access-Control-Allow-Origin",
+ value: "http://tauri.localhost",
+ },
+ {
+ key: "Access-Control-Allow-Methods",
+ value: "GET, POST, PUT, DELETE, OPTIONS",
+ },
+ {
+ key: "Access-Control-Allow-Headers",
+ value: "Content-Type, Authorization",
+ },
+ {
+ key: "Access-Control-Allow-Credentials",
+ value: "true",
+ },
+ ],
+ },
+ {
+ source: "/api/desktop/(.*)",
+ headers: [
+ {
+ key: "Access-Control-Allow-Origin",
+ value: "tauri://localhost/",
},
{
key: "Access-Control-Allow-Methods",