Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

wip: CORS issue probing

Richie McIlroy216e57a4ba38
diff --git a/apps/desktop/src/components/windows/inner/Recorder.tsx b/apps/desktop/src/components/windows/inner/Recorder.tsx
index 2dc781df5..634764faf 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`,
{
+ method: "GET",
cache: "no-store",
headers: {
Authorization: `Bearer ${token}`,
diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts
index 27e68587a..292123ef4 100644
--- a/apps/web/middleware.ts
+++ b/apps/web/middleware.ts
@@ -3,9 +3,11 @@ import { NextRequest, NextResponse } from "next/server";
export function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith("/api/desktop/")) {
const token = request.headers.get("authorization")?.split(" ")[1];
+
const cookieIsSet = request.cookies.get("next-auth.session-token");
if (cookieIsSet) {
+ console.log("Cookie is set");
return NextResponse.next();
}
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs
index 8af1118e9..6f09f7b0b 100644
--- a/apps/web/next.config.mjs
+++ b/apps/web/next.config.mjs
@@ -60,19 +60,19 @@ const nextConfig = {
],
},
{
- source: "/(.*)",
+ source: "/api/desktop/(.*)",
headers: [
{
key: "Access-Control-Allow-Origin",
- value: "https://*.amazonaws.com",
+ value: "tauri://localhost",
},
{
key: "Access-Control-Allow-Methods",
- value: "GET",
+ value: "GET, POST, PUT, DELETE, OPTIONS",
},
{
- key: "Access-Control-Allow-Credentials",
- value: "true",
+ key: "Access-Control-Allow-Headers",
+ value: "Content-Type, Authorization",
},
],
},
@@ -81,7 +81,7 @@ const nextConfig = {
headers: [
{
key: "Access-Control-Allow-Origin",
- value: "*",
+ value: "http://localhost:3001",
},
{
key: "Access-Control-Allow-Methods",
diff --git a/packages/database/package.json b/packages/database/package.json
index bb10cba6b..80366b431 100644
--- a/packages/database/package.json
+++ b/packages/database/package.json
@@ -18,6 +18,7 @@
"drizzle-orm": "^0.29.3",
"mysql2": "^3.7.0",
"nanoid": "^5.0.4",
+ "next": "14.1.0",
"next-auth": "^4.24.5",
"react-email": "^1.10.1",
"resend": "3.0.0"