gaurv007 commited on
Commit
cdcee3d
·
verified ·
1 Parent(s): 44d21af

v4.0: Web API analyze route — forward auth token to backend

Browse files
Files changed (1) hide show
  1. web/app/api/analyze/route.ts +12 -2
web/app/api/analyze/route.ts CHANGED
@@ -1,4 +1,5 @@
1
  import { NextRequest, NextResponse } from "next/server";
 
2
 
3
  const API_URL = process.env.CLAUSEGUARD_API_URL || "https://gaurv007-clauseguard-api.hf.space";
4
 
@@ -14,10 +15,19 @@ export async function POST(req: NextRequest) {
14
  );
15
  }
16
 
17
- // Forward to backend API v2.0 (full text, clauses split server-side)
 
 
 
 
 
 
 
 
 
18
  const response = await fetch(`${API_URL}/api/analyze`, {
19
  method: "POST",
20
- headers: { "Content-Type": "application/json" },
21
  body: JSON.stringify({ text, source_url }),
22
  });
23
 
 
1
  import { NextRequest, NextResponse } from "next/server";
2
+ import { createClient } from "@/lib/supabase/server";
3
 
4
  const API_URL = process.env.CLAUSEGUARD_API_URL || "https://gaurv007-clauseguard-api.hf.space";
5
 
 
15
  );
16
  }
17
 
18
+ // Forward auth token to backend
19
+ const headers: Record<string, string> = { "Content-Type": "application/json" };
20
+ try {
21
+ const supabase = await createClient();
22
+ const { data: { session } } = await supabase.auth.getSession();
23
+ if (session?.access_token) {
24
+ headers["Authorization"] = `Bearer ${session.access_token}`;
25
+ }
26
+ } catch {}
27
+
28
  const response = await fetch(`${API_URL}/api/analyze`, {
29
  method: "POST",
30
+ headers,
31
  body: JSON.stringify({ text, source_url }),
32
  });
33