Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

no credentials (#766)

Ameer Al Ashhabe965af4c2ce2
diff --git a/apps/web/app/api/playlist/route.ts b/apps/web/app/api/playlist/route.ts
index 2c888cdf3..6d5523019 100644
--- a/apps/web/app/api/playlist/route.ts
+++ b/apps/web/app/api/playlist/route.ts
@@ -12,15 +12,28 @@ import { Hono } from "hono";
import { zValidator } from "@hono/zod-validator";
import z from "zod";
import { handle } from "hono/vercel";
+import { cors } from "hono/cors";
-import { corsMiddleware, withOptionalAuth } from "../utils";
+import { withOptionalAuth } from "../utils";
import { userHasAccessToVideo } from "@/utils/auth";
+import { allowedOrigins } from "../utils";
export const revalidate = "force-dynamic";
const app = new Hono()
.basePath("/api/playlist")
- .use(corsMiddleware)
+ .use(
+ cors({
+ origin: allowedOrigins,
+ allowMethods: ["POST", "OPTIONS"],
+ allowHeaders: [
+ "Content-Type",
+ "Authorization",
+ "sentry-trace",
+ "baggage",
+ ],
+ })
+ )
.use(withOptionalAuth)
.get(
"/",
diff --git a/apps/web/app/api/utils.ts b/apps/web/app/api/utils.ts
index 8923a911b..0b3944aca 100644
--- a/apps/web/app/api/utils.ts
+++ b/apps/web/app/api/utils.ts
@@ -1,11 +1,9 @@
import { getCurrentUser } from "@cap/database/auth/session";
import { cookies } from "next/headers";
import { createMiddleware } from "hono/factory";
-import { buildEnv, serverEnv } from "@cap/env";
+import { buildEnv } from "@cap/env";
import { cors } from "hono/cors";
import { eq } from "drizzle-orm";
-import { getServerSession, Session } from "next-auth";
-import { authOptions } from "@cap/database/auth/auth-options";
import { Context } from "hono";
import { db } from "@cap/database";
import { authApiKeys, users } from "@cap/database/schema";
@@ -65,7 +63,7 @@ export const withAuth = createMiddleware<{
await next();
});
-const allowedOrigins = [
+export const allowedOrigins = [
buildEnv.NEXT_PUBLIC_WEB_URL,
"http://localhost:3001",
"http://localhost:3000",